function WebOffice2015() {
	this.dVersion="3.0.0.2";
    this.dUpdateDate="2016-12-15";
    var ISO;//����������ֵ
    
	var png2 = "hex:89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773DF8000000097048597300000B1200000B1201D2DD7EFC00000122494441544889ED95BD4AC35018869F98C645842A1497CECE422797A290730552C824F5127A25E7120A5D1208DE408EA064C91470EAE05010BA8883A368A59F4B23A50D6D6C9A0EE23B9D9FEFBC0F7C2FE71C4B44A8527B95BAEF0250CB064AA9ADF6CA18630120228808AEEBCAA27CDF5F5A2B5233F34244FE4006FF80B5AAAD2B0882A03A80E779457D9C85F9A410A0A06C601AA6B106E8B4DABD288AEC6D016C603A484C3F190DBB00EF9F1FF5EB73759315940979C91C20190DBB83C4F4CB029C3CF33CC8C62D0AD358E799CF438E0F0E9FADECC3514A8931A6A8BF037C013CBD8C2FF4DDEDFDFC66CFBDBA3C3D693EC0E62D9A00859EF7DDDE64A5D4AF0E6BADD96FD457D6FC645046611AEBF1DBEB1940F3A8F1D869B57B5B05AC52E5197C03B5E7B70EA44B70540000000049454E44AE426082";

	
    this.Ashell = null;
    
	this.RecvPercent = 0;
    this.nTotleBytes = -1;
    this.nRecvedBytes = -1;
    this.nSendedBytes = -1;
	this.SingleFileName = "";
    this.FileType = ""; // FileType:�ĵ����� .doc .xls .wps
    this.obj; 					// obj��object ����
    this.Status = "";               //Status��״̬��Ϣ
    // ö����ʾϵͳ�Ϳؼ��������ضԻ�������
    this.ShowDialog = {
        DialogNew: 0, // �½�����
        DialogOpen: 1, // ��
        DialogSaveAs: 2, // ����Ϊ
        DialogSaveCopyAs: 3, // ����Ϊ����
        DialogPrint: 4, // ��ӡ
        DialogPageSetup: 5, // ��ӡ����
        DialogProperties: 6
        // �ĵ�����
    }
    this.FileName = ""; 		//FileName:�ĵ�����

    this.EditType = 0;

	this.UserName ="";
    this.setObj = function (object) {// ����2015����
        this.obj = object;
        this.WebObject = this.obj; //����VBA���ö���

    }

    this.DocType = {// ö�������ĵ���������ֻ�о�word 0,execl 1
        WORD: 0,
        EXECL: 1
    };
    this.HttpMethod = {
        Get: 0,        //Http����get��ʽ
        Post: 1      //Http����post��ʽ
    };

    this.DownloadedFileTempPathName = "";
    this.DOWN = "\\WebOffice\\Down\\"//ָ������·������������
    this.UP = "\\WebOffice\\Up\\"//ָ������·������������

    this.FilePath = null;  //�ĵ�·��
    this.TmpFile = null;   //��ʱ���ص��ĵ����ƣ�������·����
    this.tempInsertName = ""; //�����ļ����ļ�����

    this.DocTypeValue = { DOC: 0, DOCX: 16, XLS: 56, XLSX: 51, WPS: 0, ET: 56 }; //ö�����е��ĵ�����ֵ�û�������

    this.DocSuffixType = { 0: ".doc", 12: ".docx", 56: ".xls", 51: ".xlsx", 0: ".wps", 56: ".et" }; //���ݴ��ĵ����ͣ�����ȡ��׺����

    this.setVersion = -1;
    this.OfficeVersion = { v2003: 1, vOther: 0}  //�ж�Office�汾�����ֻҪ���ڱ��浽����

    this.WebObject = null; //����WebObject���󣬷������VBA ����

    this.sendMode = null //�����첽����ģʽ

    this.iWebOfficeTempName = "iWebOfficeTempName.doc"

   //设置控件标题栏上的标题
    this.Caption = "智慧文档";
    this.SetCaption = function(){
		this.Caption = "智慧文档";
		this.obj.Caption = this.Caption;
    }
    //������дǩ���û�
    this.SetUser = function(username){
		this.obj.User = username;
	}

    this.CheckFile = function(vaul){


        this.obj.bCheckFile = vaul;
    }

    /*
    * @deprecated:�½�һ���ĵ���
    */
    this.CreateFile = function () {
		
        var docType = this.getDocType(this.FileType); // ��ȡ�ĵ�����
		
        switch (docType) {
            case this.DocType.WORD:
				
                this.obj.CreateNew("KWPS.Document"); // ����word
                break;
            case this.DocType.EXECL:
                this.obj.CreateNew("Excel.Sheet"); // ����execl
                break;
       
            case this.DocType.PICTURE:
                this.obj.CreateNew("iWebPicture.iWebPictureMain"); // ����
                break;
            default:
                this.obj.CreateNew("Word.Document"); // Ĭ�ϴ���word�ĵ�
                break;
        }
    }

    /*�����ļ�*/
    this.WebSave = function () {
        var httpclient = this.obj.Http; //����http���� 
        httpclient.Clear();               
        this.WebSetMsgByName("USERNAME", this.UserName);
        this.WebSetMsgByName("RECORDID", this.RecordID);
        this.WebSetMsgByName("TEMPLATE", this.Template);
        this.WebSetMsgByName("SUBJECT", this.Subject);
        this.WebSetMsgByName("AUTHOR", this.Author);
        this.WebSetMsgByName("HTMLPATH", this.HTMLPath);
        this.WebSetMsgByName("FILETYPE", this.FileType);
        this.WebSetMsgByName("OPTION", "SAVEFILE");
        this.WebSetMsgByName("FILENAME", this.FileName); //����FileName
		var res = this.WebSaveLocalFile(this.getFilePath() + this.FileName);
		//this.FuncExtModule.alert(this.obj.DocMd5);
		this.WebSetMsgByName("MD5", this.obj.DocMd5); //��ǰ̨�ĵ�md5ֵ���͸���̨
		//alert(res);
		//alert(this.getFilePath() + this.FileName);
		//�ĵ����ر���ʧ��ʱ�����ϴ����������������𻵷������ϵ�ԭ�ĵ�
		if(res == 0){
			this.sendMode = "SaveFile";
			if (this.SAVEFILE(httpclient, this.FilePath + this.FileName)) {
				var aaa=httpclient.GetResponseHeader("ISO");//��ȡ����ֵ
				//this.FuncExtModule.alert("����������ֵ:"+aaa);
				this.Status = aaa;
				//this.FuncExtModule.alert("123");
				//this.Close();
				return true;
			}
			else
			{
				this.Status = "�����ĵ�ʧ��";
				return false;        	
			}
		}else{
			this.Status = "�����ĵ�ʧ��";
			return false; 
		}

    }

    this.SAVEFILE = function (httpclient, FileName) {//ʱ��������OPTIONֵΪ��SAVEFILE
        httpclient.AddForm("FormData", this.WebSendMessage());
        httpclient.AddFile("FileData", FileName);    //��Ҫ�ϴ����ļ�
        this.WebClearMessage();
	     httpclient.ShowProgressUI = true;           //���ؽ�����
//alert( this.WebUrl);
        if (httpclient.Open(this.HttpMethod.Post, this.WebUrl, false)) ////true �첽��ʽ falseͬ��
        {
            if (!httpclient.Send()) {

            	return false;
            }else{            
           httpclient.Clear();
            return true;
            }
        }     
        return false;
    }

	this.GetFileType = function(downloadLink)
	{
		var filename=downloadLink;
		var index1=filename.lastIndexOf(".");
		var index2=filename.length;
		var postf=filename.substring(index1,index2);//后缀名
		
		this.FileType = postf;
	}
	this.GetSingleFileName = function(downloadLink)
	{
		var filename=downloadLink;
		var index1=filename.lastIndexOf("/");
		var index2=filename.length;
		var postf=filename.substring(index1+1,index2);//后缀名
		
		this.SingleFileName = postf;
	}

	/* 打开本地文档	*/
	this.WebOpenLocalFile = function(filePath) 
	{
		if (this.getDocType(this.FileType) == this.DocType.PICTURE) {
			try {
				this.obj.ActiveDocument.WebOpenLocalFile(filePath);
				this.Status = "打开本地文档成功";
				return 0;
			} catch (e) {
				this.Status = "打开本地文档失败";
				return -1;
			}
		}
		return this.obj.Open(filePath);
	}

	this.WebOpen2 = function(downloadLink)
	{	
		console.log("downloadLink---------------->",downloadLink);
		this.Status = "成功";
		var httpclient = this.obj.Http; // 设置http对象
		
		this.FileType = ".docx";
		this.FileName = downloadLink;
		///this.GetFileType(downloadLink);
		console.log("fileType",this.FileType);

		//this.GetSingleFileName(downloadLink);
		this.SingleFileName = "test.docx"
		console.log("SingleFileName",this.SingleFileName);
		if (httpclient.Open(this.HttpMethod.Get, downloadLink, false))
        {
            if (httpclient.Send()) 
            {
            	if (this.hiddenSaveLocal(httpclient, this, false, false)) {
					console.log("this.DownloadedFileTempPathName",this.DownloadedFileTempPathName);
					var mSaveResult = this.WebOpenLocalFile(this.DownloadedFileTempPathName);
					if (mSaveResult == 0) { // 打开本地磁盘文件
						this.getOfficeVersion();// 打开文档后，判断当前office版本
						return true;
					}else if(mSaveResult == 1){
						var windows = window.confirm("可能当前授权码错误，请确认iWebOffice2015.js的授权是否正确（或乱码）"
								+ "\r\r单击“确定”关闭。单击“取消”继续。");
						this.Status = "可能当前授权码错误，请确认iWebOffice2015.js的授权是否正确（或乱码）";
						if (windows == 1) {
							window.close();
							return false;
						}
					}else if(mSaveResult == 2){
						var windows = window.confirm("没有找到文档，请确认WebOpenLocalFile打开文档的路径是否正确"
								+ "\r\r单击“确定”关闭。单击“取消”继续。");
						this.Status = "有找到文档，请确认WebOpenLocalFile打开文档的路径是否正确";
						if (windows == 1) {
							window.close();
							return false;
						}
					}else if(mSaveResult == 3){
						var windows = window.confirm("没有权限导致文档打开失败，请用管理员身份运行浏览器后重试"
								+ "\r\r单击“确定”关闭。单击“取消”继续。");
						this.Status = "没有权限导致文档打开失败，请用管理员身份运行浏览器后重试";
						if (windows == 1) {
							window.close();
							return false;
						}
					}else if(mSaveResult == 4){
						var windows = window.confirm("文件可能损坏，请确定服务器文档是否已经损坏"
								+ "\r\r单击“确定”关闭。单击“取消”继续。");
						this.Status = "文件可能损坏，请确定服务器文档是否已经损坏";
						if (windows == 1) {
							window.close();
							return false;
						}
					}else if(mSaveResult == 5){
						var windows = window.confirm("未安装Office或者注册表有损坏"
								+ "\r\r单击“确定”关闭。单击“取消”继续。");
						this.Status = "未安装Office或者注册表有损坏";
						if (windows == 1) {
							window.close();
							return false;
						}
					}else if(mSaveResult == 6){
						var windows = window.confirm("文件被占用，请结束Office进程后重试"
								+ "\r\r单击“确定”关闭。单击“取消”继续。");
						this.Status = "文件被占用，请结束Office进程后重试";
						if (windows == 1) {
							window.close();
							return false;
						}
					}else {
						var windows = window.confirm("打开文档时未知错误！错误码为： "
										+ mSaveResult
										+ "\r\r单击“确定”关闭。单击“取消”继续。");
						this.Status = "打开文档时未知错误！错误码为： "
								+ mSaveResult;
						if (windows == 1) {
							window.close();
							return false;
						}
					}
				} else {
					// 失败后，this.Status的值由hiddenSaveLocal返回
					this.Status = "保存文档到本地 失败";
					console.error("保存文档到本地 失败");
					return false;
				}
            }else{
				console.error("发送失败");
			}
        }else{
			console.error("打开文件失败");
		}
	}

	this.WebOpenNetWork = function(url,fileName){
		var fs = this.obj.FileSystem; //WebOffice����������ƣ�
        var filePath = fs.GetSpecialFolderPath(0x1a) + this.obj.DOWN;
        fs.CreateDirectory(filePath);
		filePath += fileName;
		console.log("filePath",filePath);
		console.log("this.obj.DOWN",this.obj.DOWN);
		this.obj.FuncExtModule.WebDownLoadFile(url,filePath);
		this.obj.FuncExtModule.WebOpenLocalFile(filePath);
	}

	/**
	 * 查找并高亮文字
	 * @param {String} findText 查找文字
	 * @param {Number} highlinghtIndex 高亮色号
	 * @param {Boolean} forward 向前或向后查找
	 */
	this.findAndHighlightText = function(findText,highlinghtIndex,forward){
		return this.obj.FindAndHighlightText(findText,highlinghtIndex,forward);
	}

		/**
	 * 查找并高亮文字
	 * @param {String} findText 查找文字
	 * @param {Number} highlinghtIndex 高亮色号
	 * @param {Boolean} forward 向前或向后查找
	 */
	this.replaceHighlightText = function(findText){
		this.obj.ReplaceHighlightText(findText);
	}


    /*�ӷ�������ȡ�ĵ����򿪣���RecordIDָ�����ļ� */
    this.WebOpen = function (mBoolean) {
    	if(this.nRecvedBytes != -1)
            return false;
    	
    	//alert("WebOpen 1");
        var httpclient = this.obj.Http; //����http����
        httpclient.Clear();
        this.WebSetMsgByName("USERNAME", this.UserName); //����UserName
        this.WebSetMsgByName("FILENAME", this.FileName); //����FileName
        this.WebSetMsgByName("FILETYPE", this.FileType); //����FileType
        this.WebSetMsgByName("RECORDID", this.RecordID); //����RecordID
        this.WebSetMsgByName("OPTION", "LOADFILE");     //��������LOADFILE
        httpclient.AddForm("FormData", this.WebSendMessage()); //�������Զ���json �����ʽ��
        this.WebClearMessage();                         //�������WebSetMsgByName����
        this.sendMode = "OpenFile";
        //alert(this.LOADFILE(httpclient));
		
		if (this.LOADFILE(httpclient)) {                //Http���ط������ļ�
			var httpclient = WebOffice.WebObject.Http;
	        var aaa=httpclient.GetResponseHeader("ISO");//��ȡ����ֵ
	        //alert("����������ֵ:"+aaa);
	        this.Status=aaa;
        	//alert("WebOpen 2");
            //this.Status = "���ĵ��ɹ�";               //Status��״̬��Ϣ 
            return true;
        }
    	//alert("WebOpen 3");
        this.Status = "���ĵ�ʧ��";               //Status��״̬��Ϣ 
        return false;
    }
    
    this.LOADFILE = function (httpclient) 
    { 
    	//Http �����ĵ�
    	//alert("LOADFILE 1");
    	httpclient.ShowProgressUI = true;//���ؽ�����
		//alert(this.WebUrl);
        if (httpclient.Open(this.HttpMethod.Post, this.WebUrl, false)) //true �첽��ʽ falseͬ��
        {
        	//��������첽��ʽ���ĵ�
        	//alert("LOADFILE 2");
            if (httpclient.Send()) 
            {
            	//alert("LOADFILE 3"); 
				//alert(httpclient.ResponseText);
				//alert(httpclient.GetAllResponseHeaders());
				//alert(httpclient.ResponseBody);
                if (httpclient.GetResponseHeader("MsgError") == "404") 
                {
                	//alert("LOADFILE 4");
                	//�жϷ������Ƿ�����ļ�
                    //this.CreateFile();
                    //alert(" CreateFile sucess");
					//var ret = this.getOfficeVersion();//���ĵ����жϵ�ǰoffice�汾
                    //alert(ret);
					httpclient.Clear();
                    return false;
                }
                httpclient.Clear();
                if (this.hiddenSaveLocal(httpclient, this, false, false/*, Math.round(Math.random() * 100000)*/)) 
                {
                	//���سɹ�ʱ
                	//alert("download to temp file:" + this.DownloadedFileTempPathName);
                	
				    if(this.OpenLocalFile(this.DownloadedFileTempPathName)==0)
				    { //�򿪱��ش����ļ�
				    	
						this.getOfficeVersion();//���ĵ����жϵ�ǰoffice�汾
				    	return true;
				    }
				    else
				    {
				    	var windows = window.confirm("���ĵ����󣬿��ܵ�ǰ�༭������֧�ֵ�ǰ��ʽ��\r\r������ȷ�����رա�������ȡ����������");
				    	if(windows == 1)
				    	{
				    		window.close(); 
				    	}
				    	return false;
				    }
                }
            }
            return false;
        }
    }
	


    this.EnableSignature = function (vaul) {

        try {
            this.obj.ActiveDocument.Application.COMAddIns.Item("iSignatureWord.WordApp").Connect = vaul;
        }
        catch (e) {
            return;
        }

    }
	
	/*���ô��ĵ��Ƿ���ʾ������*/
	this.ShowOpenProgress = function(mValue)
	{
		//alert(mValue);
		this.obj.Style.ShowOpenProgress = mValue;
		//alert("1234555");
	}
	
	/*����û�а�װOffice360ǩ��ʱ���ؼ��д��ĵ����Ƿ�������¼�ˢ�¹���*/
	this.UpdateSignature = function(mValue)
	{
		//alert(mValue);
		this.obj.Style.UpdateSignature = mValue;
	}

	//用于取得文件内容
	this.WebGetWordContent = function(){
		if(this.FileType == ".doc" || this.FileType == ".docx"){
			return this.obj.ActiveDocument.Content.Text; //获取word文档内容
		}
		return "";  
	}

	//用于文档对比
	this.WebDocumentCompare = function(){
		this.obj.FuncExtModule.WebDocumentCompare("c:\\Doc1.doc","c:\\Doc2.doc", "c:\\result.doc");
	}
    
    /*�򿪱��ش����ļ�*/
    this.OpenLocalFile = function (filePath) {
    	//alert(filePath);
        if (this.getDocType(this.FileType) == this.DocType.PICTURE) {
            try {
                //this.obj.CreateNew("iWebPicture.iWebPictureMain");
                this.obj.ActiveDocument.WebOpenLocalFile(filePath);
                return 0;
            }
            catch (e) {
                return -1;
            }
        }
		var res = this.obj.Open(filePath);
		if(res == 0)
		{
			//alert("0�ĵ��򿪳ɹ�");
			//alert(this.obj.FileSystem.GetFileSize(filePath));
		}else if(res == 1)
		{
			alert("1copyright���ò���");
		}else if(res == 2)
		{
			alert("2�ļ�������");
		}else if(res == 3)
		{
			alert("3û��Ȩ��");
		}else if(res == 4)
		{
			alert("4�ĵ���");
		}else if(res == 5)
		{
			alert("5δ�ҵ�CLSID");
		}else if(res == 6)
		{
			alert("6�ļ���ռ��");
		}else if(res == -1)
		{
			alert("-1����δ֪����");
		}
		return res;
    }

    /*���浽����  isHidden �Ƿ������ļ���isInsertFile�Ƿ��ǲ����ļ�*/
    this.hiddenSaveLocal = function (httpclient, webOffice, isHidden, isInsertFile, OtherName) {
        if (isHidden) {
            httpclient.Hidden = true; //�����ļ�
        }
        var tempName = "";
        var fs = webOffice.obj.FileSystem; //WebOffice����������ƣ�
        var filePath = fs.GetSpecialFolderPath(0x1a) + webOffice.DOWN;
        //var filePath = fs.GetSpecialFolderLocation(0x20) + webOffice.DOWN +  fs.GetFolderEncryptCode(1) + "\\";
		//var filePath = fs.GetSpecialFolderLocation(0x1a) + webOffice.DOWN +  fs.GetFolderEncryptCode(1) + "\\";
        //alert(filePath);
        fs.CreateDirectory(filePath);

        webOffice.FilePath = filePath; //��������·������򿪵�ʱ����ȡ��
        if (httpclient.Status == 200) {
            if (isInsertFile == undefined || isInsertFile == true) {
                tempName = "temp" + webOffice.RecordID;
                webOffice.tempInsertName = tempName + webOffice.FileName;
            }
            if (OtherName == undefined || OtherName == "") {
                OtherName = webOffice.FileName;
                OtherName = Math.random() * 100000 + this.FileType;
            }
            this.DownloadedFileTempPathName = filePath + tempName + OtherName;
			console.log("hiddenSaveLocal==============>DownloadedFileTempPathName",this.DownloadedFileTempPathName);
            httpclient.ResponseSaveToFile(this.DownloadedFileTempPathName); //��ʱ�ļ�
        	httpclient.Clear();
            return true;
        }
        httpclient.Clear();
        return false;
    }

    
    //��ȡoffice�汾��Ϣ
    this.getOfficeVersion = function () {
    	var getVersion = 0.0;
        try {
    		if(this.setVersion == -1){
    			 getVersion = parseFloat(this.obj.ActiveDocument.Application.Version);
    			 this.setVersion = getVersion;
    		}else{
    			getVersion = this.setVersion;
    		}
            if (getVersion == 11.0) {
                return this.OfficeVersion.v2003;
            } else {
                return this.OfficeVersion.vOther;
            }
        } catch (e) {
            return this.OfficeVersion.v2003;
        }
    }


    //�ر��ĵ�
    this.Close = function () {
        this.obj.Close();
    }
	
    
    /*��ȡ��ʱ·��*/
    this.getFilePath = function () {
        var fs = this.obj.FileSystem; //����file����
        var filePath = fs.GetSpecialFolderPath(0x1a) + this.UP; //������ʱ·��
        //var filePath = fs.GetSpecialFolderLocation(0x20) + this.UP + fs.GetFolderEncryptCode(1) + "\\"; //������ʱ·��
        //var filePath = fs.GetSpecialFolderLocation(0x1a) + this.UP + fs.GetFolderEncryptCode(1) + "\\";
		fs.CreateDirectory(filePath); //����·��
	
        this.FilePath = filePath; //������ֵ������ɾ���ʹ�
        return this.FilePath;
    }
    
    /*
    * ��ȡ�ĵ�����
    */
    this.getDocType = function (fileType) {
        if (fileType == ".doc" || fileType == ".docx" || fileType == ".wps") {// word
            return this.DocType.WORD;
        }
        if (fileType == ".xls" || fileType == ".xlsx" || fileType == ".et") {// execl
            return this.DocType.EXECL;
        }
 
        if (fileType == ".tif" || fileType == ".jpg" ) {// execl
            return this.DocType.PICTURE;
        }
    }

    this.HookEnabled = function () {//�����Firefox��chrome������µ���iWebPlugin����������������Ҫ��load()�����¼����´���
        if (this.getDocType(this.FileType) == this.DocType.WORD) {
            this.obj.Style.ShowToolSpace = true;
            this.obj.SelectionInformationEnabled = false;
        }
        if (!((window.ActiveXObject != undefined) || (window.ActiveXObject != null) || "ActiveXObject" in window)) {
            this.obj.HookEnabled = false;
        }
    }

    /******һ���Ǵ򿪱��ش��ڴ���******/
    // �򿪱��ش���
    this.WebOpenLocal = function () {
		//alert("111");
		//alert(this.getOpenDocSuffix(this.FileType));
		//this.obj.ShowDialog(1, this.getOpenDocSuffix(this.FileType));
		
		//alert(this.ShowDialog.DialogOpen);
		//alert(this.getOpenDocSuffix(this.FileType));
		
        this.setShowDialog(this.ShowDialog.DialogOpen, this
				.getOpenDocSuffix(this.FileType));
    }
    // ��ȡ�򿪴��ڵĺ�׺
    this.getOpenDocSuffix = function (fileType) {
        if (fileType.length == 5) {
            fileType = fileType.substring(0, 4);
        }
        var exts;
		exts = "";
		//exts =   "Word Files(*.doc;*.docx;*.docm;*.dot;*.dotx;*.dotm;*.rtf)|*.doc;*.docx;*.docm;*.dot;*.dotx;*.dotm;*.rtf";
		
		if(this.isWPS() || !this.getOfficeVersion()){//�����office2003�ǲ�֧��x��ʽ���ĵ�
			exts += "*" + fileType + "x|*" + fileType + "x|";
		}
        exts += "*" + fileType + "|*" + fileType + "|";
		exts += this.getOpenSuffixName(fileType) + "(*" + fileType
		if(this.isWPS() || !this.getOfficeVersion()){//�����office2003�ǲ�֧��x��ʽ���ĵ�
			exts +=  ";*"+ fileType + "x"
		}
		exts +=  ")|*" + fileType
        if(this.isWPS()|| !this.getOfficeVersion()){//�����office2003�ǲ�֧��x��ʽ���ĵ�
        	exts += ";*" + fileType + "x";
        }
		exts += "|All File(*.*)|*.*";
		
		exts +="|";
        return exts;
    }
    //���ص�ǰ�༭��
    this.getEditVersion = function (){
       return this.obj.AppName;
    }
    //��ȡ���ĵ���������
    this.getOpenSuffixName = function (fileType) {
        var openSuffixName;
        switch (fileType) {
            case this.DocType.WORD: openSuffixName = "Word Files"; break; //����word��׺����
            case this.DocType.EXECL: openSuffixName = "Excel Files"; break; //����execl��׺����
            default: openSuffixName = "Word Files"; break;
        }
        return openSuffixName;
    }

    //���ô򿪴��ڵ����ͣ�����ͳһ����
    this.setShowDialog = function (thisType, exts) {
    	switch (thisType) {
            case this.ShowDialog.DialogOpen: this.obj.ShowDialog(thisType, exts, 0); break; //�򿪱����ĵ�
            case this.ShowDialog.DialogNew: //�½�����
            case this.ShowDialog.DialogPageSetup: //��ӡ����
            case this.ShowDialog.DialogPrint: //��ӡ
            case this.ShowDialog.DialogProperties: //�ĵ�����
            case this.ShowDialog.DialogSaveCopyAs: //����Ϊ����
            case this.ShowDialog.DialogSaveAs: //����Ϊ
            //  this.blnIE() ? this.obj.ShowDialog(thisType) : this.obj.ExecuteScript(thisType + "", "ActiveObject.ShowDialog(" + thisType + ")"); break; //�򿪴���
            
			this.obj.ShowDialog(thisType);
			default: ; break;
        }
    }
    /******End �򿪱��ش��ڴ���******/

    /*�ĵ����浽���أ��жԻ���*/
    this.WebSaveLocal = function () {
		//alert("33333");
		//alert(this.ShowDialog.DialogSaveCopyAs);
        this.setShowDialog(this.ShowDialog.DialogSaveCopyAs);
		//this.obj.ShowDialog(2, true);
		
	/*	var exts;
		exts =  "����֧�ֵ��ļ���ʽ(*.docx;*.doc;*.xlsx;*.xls;*.pdf)|*.docx;*.doc;*.xlsx;*.xls;*.pdf";
		exts += "|Word �ĵ�(*.docx)|*.docx";
		exts += "|Word 97-2003�ĵ�(*.doc)|*.doc";
		exts += "|Excel ������(*.xlsx)|*.xlsx";
		exts += "|Excel 97-2003������(*.xls)|*.xls";
		exts += "|PDF�ĵ�(*.pdf)|*.pdf";
		exts += "||";
		
		var filename = this.obj.FileSystem.FileSaveAs(exts, "Ĭ���ļ���.doc");
		var ext = filename.substring(filename.length - 3,filename.length);
		
		if(ext == "pdf")
		{
			this.obj.ActiveDocument.ExportAsFixedFormat(filename, 17);
		}
		else
		{
			//alert(filename);
			var res = this.Save(filename, 0);
			//alert(res);
		}*/
    }
    /*2015�Դ��д��ڵ�ҳ������*/
    this.WebPageSetup = function () {
        this.setShowDialog(this.ShowDialog.DialogPageSetup);
    }
    /*2015�Դ��д��ڵĴ�ӡ����*/
    this.WebOpenPrint = function () {
		this.obj.Activate(true);
        this.setShowDialog(this.ShowDialog.DialogPrint);
    }

    this.DeleteFirstRecent = function(ver)
    {
	    var register = this.obj.Register;
	    var idx = 1;
	    while(true)
	    {
		    keyA = "Item " + idx;
		    idx++;
		    keyB = "Item " + idx;
		
		    var itemB = register.QueryStringValue(0x80000001,"Software\\Microsoft\\Office\\" + ver + "\\Word\\File MRU", keyB);
		    if(itemB == null)
		    break;
		    register.SetStringValue(0x80000001,"Software\\Microsoft\\Office\\" + ver + "\\Word\\File MRU", keyA, itemB);
	    }
	    var ret = register.DeleteSubKey(0x80000001,"Software\\Microsoft\\Office\\" + ver + "\\Word\\File MRU","Item " + (idx - 1) );
    }	
    /*�ر��ĵ�*/
    this.WebClose = function(){ //����������ùر�
    	if (navigator.userAgent.indexOf("Firefox") >= 0){//ж��ʱ�򣬻������ʹ��close����
    		return;
    	}
		
    	this.Close();
/*		this.DeleteFirstRecent("16.0");
		this.DeleteFirstRecent("15.0");
		this.DeleteFirstRecent("14.0");
		this.DeleteFirstRecent("13.0");
		this.DeleteFirstRecent("12.0");
		this.DeleteFirstRecent("11.0");
		this.DeleteFirstRecent("10.0");*/
    }

    //��ӡԤ��
    this.PrintPreview = function () {
        var ret = this.obj.PrintPreview();
		//alert(ret);
		
    }
    //�˳���ӡԤ��
    this.PrintPreviewExit = function () {
        this.obj.PrintPreviewExit();
        this.obj.ActiveDocument.ActiveWindow.View.ShowFieldCodes = false;
		
    }

    /*���ļ��˵����������˵����ṩ�Ľӿ� */
    var MenuFile;
    this.AppendMenu = function (index, Caption) {
        var custommenu = this.obj.CustomMenu;
        if (MenuFile == undefined || MenuFile == null) {
            custommenu.Clear();
            MenuFile = custommenu.CreatePopupMenu();
            custommenu.Add(MenuFile, "文件(&F)");
        }
        custommenu.AppendMenu(MenuFile, index, false, Caption);
        custommenu.Update();
    }

    this.AddCustomMenu = function () {
        var custommenu = this.obj.CustomMenu;
        //�����ļ��˵�����Ŀ
        var menufile = custommenu.CreatePopupMenu();
        var menufilelv2 = custommenu.CreatePopupMenu();
        custommenu.AppendMenu(menufilelv2, 6, false, "�Զ�������˵�һ");
        custommenu.AppendMenu(menufilelv2, 7, false, "�Զ�������˵���");
        custommenu.AppendMenu(menufilelv2, 0, false, "-");
        var menufilelv3 = custommenu.CreatePopupMenu();
        custommenu.AppendMenu(menufilelv3, 8, false, "�Զ��������˵�һ");
        custommenu.AppendMenu(menufilelv3, 0, false, "-");
        custommenu.AppendMenu(menufilelv3, 9, false, "�Զ��������˵���");

        custommenu.AppendMenu(menufilelv2, menufilelv3, true, "�Զ��������˵�");

        custommenu.AppendMenu(menufilelv2, 10, false, "�Զ�������˵���");
        custommenu.AppendMenu(menufile, menufilelv2, true, "�Զ�������˵�");
        //���ļ��˵����ӵ��������˵�
        custommenu.AppendMenu(menufile, 17, false, "���ñ���");
        custommenu.AppendMenu(menufile, 18, false, "��ֹ����");
        custommenu.AppendMenu(menufile, 0, false, "-");
        custommenu.AppendMenu(menufile, 19, false, "���ô�ӡ");
        custommenu.AppendMenu(menufile, 20, false, "��ֹ��ӡ");
        custommenu.Add(menufile, "编辑(&E)");

        // //��������
        // var menuLang = custommenu.CreatePopupMenu();
        // custommenu.AppendMenu(menuLang, 22, false, "��������");
        // custommenu.AppendMenu(menuLang, 23, false, "��������(TW)");
        // custommenu.AppendMenu(menuLang, 24, false, "��������(HK)")
        // custommenu.AppendMenu(menuLang, 25, false, "Ӣ��");
		// custommenu.AppendMenu(menuLang, 26, false, "��������");
        // custommenu.Add(menuLang, "������(&N)");

        //֪ͨϵͳ���²˵�
        custommenu.Update();
    }
	
	//�Զ��幤�������Ӱ�ť
	this.AddToolButton = function(){
		
		var customtoolbar = this.obj.CustomToolbar;
		customtoolbar.AddToolButton(2,"�����ĵ�"," ", "�����ĵ�",0);
	}
	
	this.ChangeLanguage = function(lcid) {
		//alert(lcid);
        this.obj.Lcid = lcid;
    }

    /*���浽����·�� FileName������·��*/
    this.WebSaveLocalFile = function (FileName) {
        this.WebDelFile(FileName);
		//alert(FileName);
		//alert(this.getOfficeVersion());
		//alert(this.FileType.substring(1).toUpperCase());
		
        var res = this.Save(FileName, this.getOfficeVersion(), this.FileType.substring(1).toUpperCase());
		
		return res;
    }

    /*office2003�Ľӿں������Ĳ�һ�������б��浽����Ҫ���ֿ���*/
    this.Save = function (FileName, is2003, FileType)
    {


        if (this.getDocType(this.FileType) == this.DocType.PICTURE)
        {

            var res = this.obj.ActiveDocument.WebSaveLocalFile(FileName);
            return res;

        }
        if (is2003)
        {
            var res = this.obj.Save(FileName);
            return res;
        }

		//alert(FileName);
		//alert(eval("this.DocTypeValue." + FileType));
        var res = this.obj.Save(FileName, eval("this.DocTypeValue." + FileType), true);
		
		
		if(res == 0)
		{
			//alert("0�ĵ�����ɹ�");
		}else if(res == 1)
		{
			alert("1copyright���ò���");
		}else if(res == 3)
		{
			alert("3û��Ȩ��");
		}else if(res == 6)
		{
			alert("6�ļ���ռ��");
		}else if(res == 7)
		{
			alert("7�ļ�δ�򿪻�δ����");
		}else if(res == -1)
		{
			alert("-1����δ֪����");
		}
		
		return res;
    }

   
    //��ȡ����
    this.Activate = function(blnValue){
    	this.obj.Activate(blnValue);
    }
    //����word��ҳ�� ,IE��������������������Է�װ����
    this.WebPageCode = function () {
        var FunctionString = "ActiveObject.ActiveDocument.Application.Dialogs(294).Show()";
		this.obj.ActiveDocument.Application.Dialogs.Item(294).Show();
   }


    /*ExecuteScript�ɽ�ͬ������ת��Ϊ�첽�������FireFox��Chrome��������е��������ʱ��������µ�������Ӧ��ʾ������⡣*/
    this.ExecuteScript = function (mValue, StringObject) {
        this.obj.ExecuteScript(mValue, StringObject);
    }

	/**
	 * 显示隐藏控件
	 * @param {*} mValue 
	 */
	this.Hide = function(mValue){
		this.obj.Hide(mValue);
		this.obj.HidePlugin(mValue);
	}

    /*显示或隐藏标题栏*/
    this.ShowTitleBar = function (mValue) {
        var style = this.obj.Style;
        style.ShowTitleBar = mValue;
    }

	/**
	 * iWebOffice的边框类型 0 无边框 1 细边框 2 3D凸边框 3 3D凹边框 4 3D蚀刻边框 5 3D隆起边框 6 系统定义边框
	 * @param {*} mValue 
	 */
	this.BorderStyle = function (mValue) {
        this.obj.Style.BorderStyle = mValue;
    }

    /*����2015�Զ���˵���*/
    this.ShowCustomToolBar = function (mValue) {
        var style = this.obj.Style;
        style.ShowCustomToolbar = mValue;
    }

    /*����2015�˵���*/
    this.ShowMenuBar = function (mValue) {
        var style = this.obj.Style;
        style.ShowMenuBar = mValue;
    }

    /*����Office������*/
    this.ShowToolBars = function (mValue) {
    	var style = this.obj.Style;
        style.ShowToolBars = mValue;
		//style.ShowToolSpace = mValue;
    }
	/*�����۵��������������ǰ��������չ���ĵ��ô˷������۵��������������ǰ���������۵�������ô˷�����չ��������*/
	this.ToggleRibbon = function()
	{
		if(this.getDocType(this.FileType)== this.DocType.WORD )
		{
			this.obj.ActiveDocument.ActiveWindow.ToggleRibbon();
		}
	}

    /*显示或隐藏状态栏*/
    this.ShowStatusBar = function (mValue) {
        var style = this.obj.Style;
        style.ShowStatusBar = mValue;
    }

    /*����2015ȫ��*/
    this.FullSize = function (mValue) {
    	this.obj.FullSize = mValue;
    }
	
	/*iWebOffice全屏窗口风格。0：无标题风格，1：有标题风格*/
    this.FullWindowStyle = function (mValue) {
    	this.obj.FullWindowStyle = mValue;
    }
	
    /*
    * ��ʾ�����غۼ�
    * ���غۼ�ʱ֮ǰ�ĺۼ�����Ӱ��
    */
    this.WebShow = function (blnValue) {
        if (this.getDocType(this.FileType) == this.DocType.WORD) {
            this.VBAShowRevisions(blnValue);
        }
    }

    //�Ƿ�����iWebOffice�������ĵ��ı��湦��
    this.SaveEnabled = function (mBoolean) {
        this.obj.SaveEnabled = mBoolean;
    }

    //�Ƿ�����iWebOffice�������ĵ��Ĵ�ӡ����
    this.PrintEnabled = function (mBoolean) {
        this.obj.PrintEnabled = mBoolean;
    }

    /*���ñ����ĵ�*/
    this.WebSetProtect = function (Boolean, password) {
        var docType = this.getDocType(this.FileType);
        if (password == "") {
            password = "123456";
        }
        Boolean ? this.VBAProtectDocument(docType, password) : this.VBAUnProtectDocument(docType, password);
    }

    /*������ǩֲ*/
    /*this.WebSetBookmarks = function (vbmName, vbmValue) {
        this.VBASetBookmarks(vbmName, vbmValue);
    }*/
	this.WebEnableRevisions = function(mBoolean)
	{
		if(mBoolean)
		{
			if(this.getDocType(this.FileType)== this.DocType.WORD && (this.obj.ActiveDocument.ProtectionType == "-1" ))
			{
				this.obj.ActiveDocument.Protect(0);
			}
		}
		else
		{
			if(this.getDocType(this.FileType)== this.DocType.WORD && (this.obj.ActiveDocument.ProtectionType == "0" ))
			{
				this.obj.ActiveDocument.Unprotect("");
			}
		}
	}
	
	 // ����Ϣ���õ���ǩλ��
	this.WebSetBookmarks = function(vbmName, vbmValue) {
		try {
			if (this.obj.ActiveDocument.BookMarks.Exists(vbmName)) {// �ж��Ƿ���ڸ���ǩ
				var vRange = this.obj.ActiveDocument.Bookmarks.Item(vbmName).Range;
				vRange.text = vbmValue;
				this.obj.ActiveDocument.Bookmarks.Add(vbmName, vRange);
			}
		} catch (e) {
			this.Status = "����Ϊ<" + vbmName + ">����ǩ���ĵ��в�����";
			return false;
		}
	}
	
    //����ǩ����
    this.WebOpenBookMarks = function(){
    	var FunctionString = "ActiveObject.ActiveDocument.Application.Dialogs(168).Show()";
	
	this.obj.ActiveDocument.Application.Dialogs.Item(168).Show();
   }

  //��괦������ǩ
    this.WebAddBookMarks = function(BMarksName,BMarksValue){
	     if(!this.obj.ActiveDocument.BookMarks.Exists(BMarksName)){//�ж��Ƿ���ڸ���ǩ
		var BMVLength = BMarksValue.length;
              this.obj.ActiveDocument.Application.Selection.TypeText(BMarksValue);//��������
              this.obj.ActiveDocument.Application.Selection.MoveLeft(Unit = 1, Count = BMVLength);
              var StartR = this.obj.ActiveDocument.Application.Selection.Start;
              var EndR = this.obj.ActiveDocument.Application.Selection.Start + BMVLength;
              this.obj.ActiveDocument.Range(Start = StartR, End = EndR).Select();
              this.obj.ActiveDocument.Bookmarks.Add(BMarksName);//������ǩ
	     }
    }
    //��ǩ��λ
    this.WebFindBookMarks = function(BMarksName){
		var range = this.obj.Range;
		//alert(BMarksName);
		range = this.obj.ActiveDocument.Bookmarks.Item(BMarksName).Range;
		range.Select();
    }
   //ɾ����ǩ
    this.WebDelBookMarks = function(BMarksName){
    	if(this.obj.ActiveDocument.BookMarks.Exists(BMarksName)){//�ж��Ƿ���ڸ���ǩ
	    this.obj.ActiveDocument.Bookmarks(BMarksName).Delete();//ɾ����ǩ
       }
    }

    /*��ȡ��ǰ�ĵ������ͣ��Ժ�׺��������*/
    this.WebGetDocSuffix = function () {
    	try{
        var docType = this.getDocType(this.FileType); //�ж����ĵ����Ǳ���
        var FileTypeValue = 0;  //�жϴ��ĵ���ֵ 0��doc��12��docx��51��xls��56��xlsx
        if (docType == this.DocType.WORD) {  //word ��ȡvbaֵ�ķ���
	    		this.Activate(true);
            FileTypeValue = this.obj.ActiveDocument.SaveFormat;
        }
        if (docType == this.DocType.EXECL) { //Execl ��ȡ����
            this.obj.ExitExcelEditMode(); // �˳���ǰ�༭ģʽ
            FileTypeValue = this.obj.ActiveDocument.FileFormat;
		    	    if(FileTypeValue <0){ //2003��֧�ָ�����
		    	    	FileTypeValue = 56;
        }
	    	}
        return this.DocSuffixType[FileTypeValue];
    	}catch(e){
    		return this.FileType;
    	}
    }
    //iWebOffice�򿪵��ĵ�ȫ·����
    this.WebFullName = function () {
        return this.obj.FullName;
    }

/*
    this.BookMark = "";
    this.ImageName = "";
    
    this.WebInsertImage = function (BookMark, ImageName) {//����Զ��ͼƬ��BookMark�������ǩ��λ��;ImageNameԶ��ͼƬ������
        var httpclient = this.obj.Http;
        this.sendMode = "LoadImage";
        this.BookMark = BookMark;
        this.ImageName = ImageName;
    try {
    	 var URL = this.WebUrl.substring(0, this.WebUrl.lastIndexOf("/"));
 		httpclient.ShowProgressUI = false;//���ؽ�����
        if (httpclient.Open(this.HttpMethod.Post, URL + "/Document/" + ImageName, true)) {  //true �첽��ʽ falseͬ��
         			//alert(URL + "/Document1/" + ImageName);
             		httpclient.Send();
 		    		httpclient.Clear();
         }
	} catch (e) {
		// TODO: handle exception
		
		this.Status(e.description);
		
	}   
    }

    //������ǩ����ͼƬ
    this.InsertImageByBookMark = function () {
        if (this.BookMark == null || this.BookMark == 'null' || this.BookMark == "") {
            this.obj.ActiveDocument.Application.Selection.GoTo(-1, 0, 0, this.BookMark);
        }
        try {
            this.obj.ActiveDocument.Application.Selection.InlineShapes.AddPicture(this.FilePath + this.ImageName);
            this.obj.ActiveDocument.InlineShapes.Item(1).ConvertToShape();   //תΪ������
            this.obj.ActiveDocument.Shapes.Item(1).WrapFormat.Type = 5;     //0:������  1��������  2����Խ�ͻ��� 3�����������Ϸ� 4�������ͻ��� 5�����������·�  6�����������Ϸ�
            return true;
		} catch (e) {
			alert(e.description);
			
		}
    
    }
*/
    this.BookMark = "";
    this.ImageName = "";
    this.WebInsertImage = function (BookMark, ImageName) {//����Զ��ͼƬ��BookMark�������ǩ��λ��;ImageNameԶ��ͼƬ������
        var httpclient = this.obj.Http;
        this.sendMode = "LoadImage";
        this.BookMark = BookMark;
        this.ImageName = ImageName;
        var URL = this.WebUrl.substring(0, this.WebUrl.lastIndexOf("/"));
		httpclient.ShowProgressUI = false;//���ؽ�����
		//alert(URL);
        if (httpclient.Open(this.HttpMethod.Post, URL + "/Document/" + ImageName, true)) {
			//alert(URL + "/Document/" + ImageName);
            httpclient.Send();
			
			//alert("send");
		    httpclient.Clear();
			//alert("Clear");
        }
    }

    //������ǩ����ͼƬ
    this.InsertImageByBookMark = function () {
        //if (this.BookMark == null || this.BookMark == 'null' || this.BookMark == "") {
            this.obj.ActiveDocument.Application.Selection.GoTo(-1, 0, 0, this.BookMark);
        //}
		//alert("123");
        this.obj.ActiveDocument.Application.Selection.InlineShapes.AddPicture(this.FilePath + this.ImageName);
        //alert(this.FilePath + this.ImageName);
		this.obj.ActiveDocument.InlineShapes.pm_Item(1).ConvertToShape();   //תΪ������
        this.obj.ActiveDocument.Shapes.pm_Item(1).WrapFormat.Type = 5;     //0:������  1��������  2����Խ�ͻ��� 3�����������Ϸ� 4�������ͻ��� 5�����������·�  6�����������Ϸ�
        return true;
    }
    
    //�����ĵ����Ʋ����ĵ�   
    this.WebInsertFile = function () {
        var httpclient = this.obj.Http; //����http����
        this.WebSetMsgByName("FILENAME", this.FileName); //����FileName
        this.WebSetMsgByName("OPTION", "LOADFILE");     //��������LOADFILE
        httpclient.AddForm("FormData", this.WebSendMessage()); //�������Զ���json �����ʽ��
        this.WebClearMessage();                         //�������WebSetMsgByName����
        if (this.LOADFILE(httpclient)) {                //Http���ط������ļ�
            this.Status = "���ĵ��ɹ�";               //Status��״̬��Ϣ
            return true;
        }
        this.Status = "���ĵ�ʧ��";               //Status��״̬��Ϣ
        return false;


    }
	
	/* ������ʱĿ¼·��(DOWN) */
	this.DownFilePath = function()
	{
		var fs = this.obj.FileSystem;					// ��ȡfile����
		var NewDownFilePath;
		if (this.HiddenDirectory)						//���ĵ�����������Ŀ¼
		{
			NewDownFilePath = fs.GetSpecialFolderLocation(0x20) + this.DOWN
				+ fs.GetFolderEncryptCode(1) + "\\" ; 	// ������ʱ·��
		}
		else
		{
			NewDownFilePath = fs.GetSpecialFolderPath(0x1a) + this.DOWN; //������ʱ·��
		}
		return NewDownFilePath;
	}
	
	/* ɾ��ˮӡ */
	this.DelWaterMark = function(WaterMarkNmae) {
		if(this.FileType == ".doc" || this.FileType == ".docx"){
			if(this.obj.ActiveDocument.ProtectionType == "-1"){
				this.WebObject.ActiveDocument.ActiveWindow.ActivePane.View.SeekView = 9;
				var selection = this.WebObject.ActiveDocument.Application.Selection;
				//�����ĵ����Ƿ��������Ϊ��WaterMarkObjectName����ˮӡ����������ڣ���ɾ��
				var WaterCount = selection.HeaderFooter.Shapes.Count;
				if ( WaterCount > 0){
					for (var i = WaterCount; i >= 1; i--){
						if (selection.HeaderFooter.Shapes.Item(i).Name = WaterMarkNmae + i){
							selection.HeaderFooter.Shapes.Item(i).Delete();
						}
					}
				}
				this.WebObject.ActiveDocument.ActiveWindow.ActivePane.View.SeekView = 0;
				this.Status = "ɾ��ˮӡ�ɹ�";
				return true;
			}
			this.Status = "�ĵ���������ɾ��ˮӡʧ��";
			return false;
		}
		this.Status = "��Word�ĵ���ɾ��ˮӡʧ��";
		return false;
	}
	
	
	/*�����ļ�������*/
	this.WebSaveWithData = function (tableName, pkValue, batchId, fileType, batchFlag, attachType, flag, prop1, attr7, prop3) {
		var httpclient = this.obj.Http; //����http����
		httpclient.Clear();
		this.WebSetMsgByName("USERNAME", this.UserName);
		this.WebSetMsgByName("RECORDID", this.RecordID);
		this.WebSetMsgByName("OPTION", "SAVEFILE");
		this.WebSetMsgByName("FILENAME", this.FileName); //����FileName
		this.WebSetMsgByName("TABLENAME", tableName);   //�������
		this.WebSetMsgByName("PKVALUE", pkValue);       //�������ID
		this.WebSetMsgByName("BATCHID", batchId);
		this.WebSetMsgByName("FILETYPE", fileType);
		this.WebSetMsgByName("BATCHFLAG", batchFlag);
		this.WebSetMsgByName("ATTACHTYPE", attachType);
		this.WebSetMsgByName("PROP1", prop1);
		this.WebSetMsgByName("ATTR7", attr7);
		this.WebSetMsgByName("PROP3", prop3);
		this.WebSetMsgByName("SAVEDATAfLAG", 'Y');
		this.WebSetMsgByName("fileNewName", this.fileNewName);
		this.WebSaveLocalFile(this.getFilePath() + this.FileName);
		if (flag) {
			this.Close();
		}
		if (this.SAVEFILE(httpclient, this.FilePath + this.FileName)) {
			this.Status = "�����ļ��ɹ�";
			return true;
		}
		this.Status = "�����ļ�ʧ��";
		return false;
	}
	
	/* ����ͼƬˮӡ */
	this.AddGraphicWaterMark = function(WaterMarkNmae,graphicAppendixId) 
	{
		if(this.FileType == ".doc" || this.FileType == ".docx")
		{
			//WebOffice.WebUrl = getIpPath() + CMS_END_CTX + "/cms/office/loadFile";
			//WebOffice.RecordID = graphicAppendixId;
			if(this.blnIE()){
				var intPageTotal = this.WebObject.ActiveDocument.Application.ActiveDocument.BuiltInDocumentProperties(14);
			}else{
				var intPageTotal = this.WebObject.ActiveDocument.Application.ActiveDocument.BuiltInDocumentProperties.Item(14).Value();
			}
			intPage = parseInt(intPageTotal);
			var selection = this.WebObject.ActiveDocument.Application.Selection;
			if(this.obj.ActiveDocument.ProtectionType == "-1"){
				this.DelWaterMark(WaterMarkNmae);
				//��ȡ������ʱĿ¼
				var ImagePath = this.DownFilePath();
				//��Ŀ·����Document��"WaterMark.jpg"
				var ImageName = "WaterMark.jpg";
				//����ͼƬ��ʼ ��һ��������ͼƬ������Document�´��ڣ��ڶ����Ǳ�����ʱ·��
				this.DownloadToFile(ImageName,ImagePath);
				var j = 1;
				for(var i=1;i<=intPage;i++){
					selection.GoTo (What = 1, Which = 1, Count = i);
				try {
					console.log("aa");
					this.WebObject.ActiveDocument.ActiveWindow.ActivePane.View.SeekView = 9; //wdSeekCurrentPageHeader
					console.log("bb");
					this.WebObject.ActiveDocument.Application.Selection.ClearFormatting(); //ȥҳ�����
					console.log("cc");
					/////���������������������ͼƬ����һ������Ϊ����·��ͼƬ///////
					WebOffice.WebObject.ActiveDocument.Shapes.AddPicture;
					console.log("dd");
					selection.HeaderFooter.Shapes.AddPicture(ImagePath + ImageName , false, true).Select(); //ˮӡλ��
					console.log("ee");
					var shapeRange = selection.ShapeRange;
					shapeRange.Name = WaterMarkNmae+j;  //ˮӡ������
					j = j + 1;
					console.log("ff");
					shapeRange.LockAspectRatio = true;
					//shapeRange.Height = WebOffice.WebObject.Application.CentimetersToPoints(30);    //�߶�
					//shapeRange.Width = WebOffice.WebObject.Application.CentimetersToPoints(18.5);     //����
					console.log("gg");
					shapeRange.WrapFormat.AllowOverlap = true;
					shapeRange.WrapFormat.Side = 3;				//wdWrapNone
					shapeRange.WrapFormat.Type = 3;
					shapeRange.RelativeHorizontalPosition = 0;	//wdRelativeVerticalPositionMargin
					shapeRange.RelativeVerticalPosition = 0;	//wdRelativeVerticalPositionMargin
					shapeRange.Left = -999995;					//wdShapeCenter
					shapeRange.Top = -40;					//wdShapeCenter
					console.log("hh");
					this.WebObject.ActiveDocument.ActiveWindow.ActivePane.View.SeekView = 0; //wdSeekMainDocument
					console.log("ii");
					this.Status = "ˮӡ���ӳɹ�";
				}catch(e) {
					this.Status = "ˮӡ���ӳɹ�" + e.description;
					return false;
				}
			}
				return true;
			}else{
				this.Status = "�ĵ�������������ˮӡʧ��";
				return false;
			}
		}
		this.Status = "��Word�ĵ�������ˮӡʧ��";
		return false;
	}
	
	//�����ǩ����
	this.UnprotectBookMarkContent = function (PassWord) {
		this.WebSetProtect(false, PassWord);
		WebOffice.WebObject.ActiveDocument.DeleteAllEditableRanges(-1);
	}
	
	//������ǩ
	this.ProtectBookMarkContent = function (BookMarkName, PassWord) {
		try {

			if (WebOffice.WebObject.ActiveDocument.ProtectionType != -1) {
				WebOffice.WebObject.ActiveDocument.Unprotect(PassWord);
				WebOffice.WebObject.ActiveDocument.DeleteAllEditableRanges(-1);
			}
			var nCount = WebOffice.WebObject.ActiveDocument.Bookmarks.Count;
			var RangeArray = [];
			var i;
			for (i = 1; i <= nCount; i++) {
				var sBookMarK;
				sBookMarK = WebOffice.WebObject.ActiveDocument.Bookmarks.Item(i).Name;
				if (sBookMarK.indexOf('_ARTICLE_PURPOSE') > 0) {
					RangeArray.push(WebOffice.WebObject.ActiveDocument.Bookmarks.Item(i).Range);
				}
			}
			var nRangeCount = 0;
			nRangeCount = RangeArray.length;
			if (nRangeCount == 0) {
				return;
			}

			//��range�����������򣬰�range��Endֵ��С����������
			var k = 0;
			for (k = 0; k < nRangeCount; k++) {
				for (var j = k + 1; j < RangeArray.length; j++) {
					if (RangeArray[k].End > RangeArray[j].End) {
						var tmp = RangeArray[k];
						RangeArray[k] = RangeArray[j];
						RangeArray[j] = tmp;
					}
				}
			}
			//���ӿɱ༭��������������֣� ͷ�� + �м� + β��

			var a = WebOffice.WebObject.ActiveDocument.Range(0, RangeArray[0].start);   //

			a.Editors.Add(-1);         //���ӿɱ༭����

			for (i = 0; i < nRangeCount - 1; i++) {

				var b = WebOffice.WebObject.ActiveDocument.Range(RangeArray[i].End, RangeArray[i + 1].start);
				console.log(RangeArray[i].End, RangeArray[i + 1].start, i);
				b.Editors.Add(-1);         //���ӿɱ༭����

			}

			var c = WebOffice.WebObject.ActiveDocument.Range(RangeArray[nRangeCount - 1].End, WebOffice.WebObject.ActiveDocument.Range().End - 1);
			c.Editors.Add(-1);        //���ӿɱ༭����

			var flag = WebOffice.WebObject.ActiveDocument.Protect(3, false, PassWord, false, false);//������wdAllowOnlyReading=3
			if (flag = true) {
				// alert("successs");
			} else {
				alert("fail");
			}
			WebOffice.WebObject.ActiveDocument.ActiveWindow.View.ShadeEditableRanges = false  //ɾ�����򱣻�����
		} catch (e) {
			return;
		}

	}
	
	//����ҳü����
	this.DelWordHeader = function() {
		if(this.FileType == ".doc" ||  this.FileType == ".docx"){
			if(WebOffice.WebObject.Application.ActiveDocument.ProtectionType == "-1"){
				WebOffice.WebObject.Application.ActiveDocument.ActiveWindow.ActivePane.View.SeekView = 9;
				var selection = WebOffice.WebObject.ActiveDocument.Application.Selection;
				selection.WholeStory();
				selection.Delete();
				WebOffice.WebObject.ActiveDocument.ActiveWindow.ActivePane.View.SeekView = 0;
				// alert("����ҳü���ݳɹ�");
				return true;
			}
			alert("�ĵ�������");
			return false;
		}
		alert("����word�ĵ�");
		return false;
	}

	this.KGOpenWebFile = function(url){
		console.log("KGOpenWebFile",this.obj.ActiveDocument);
		console.log("KGOpenWebFile",this.obj.ActiveDocument.Application);
		console.log("this.obj.ActiveDocument.KGOpenWebFile",this.obj.ActiveDocument.KGOpenWebFile);
		console.log("FuncExtModule.KGOpenWebFile",this.obj.ActiveDocument.Application.KGOpenWebFile);
		this.obj.KGOpenWebFile(url,false)
	}


	this.downloadWebFile = function (url) {
		var httpclient = this.obj.Http;
		httpclient.Clear();
		if (httpclient.Open(this.HttpMethod.Get, url, false)) {
			if (httpclient.Send()) {
				if (httpclient.Status == 200) {
					httpclient.ResponseSaveToFile();
				}else{
					console.log("下载失败请检查URL是否正确");
				}
			}else{
				console.log("数据包发送失败");
			}
			httpclient.Close();
		}else{
			console.log("打开连接失败");
		}
	}

    //�����ĵ�
    this.DownloadToFile = function (DownFileName, SavePathName) {
        var httpclient = this.obj.Http;
        var URL = this.WebUrl.substring(0, this.WebUrl.lastIndexOf("/"));
        httpclient.ShowProgressUI = true;//���ؽ�����
        if (httpclient.Open(this.HttpMethod.Get, URL + "/Document/" + DownFileName, false)) {//ָ������ģ�������
			if (httpclient.Send()) {
                if (httpclient.Status == 200) {
                	httpclient.ResponseSaveToFile(SavePathName + DownFileName);
                	httpclient.Clear();
                    return true;
                }
            }
        }
        httpclient.Close();
        return false;
    }


    /**
    ������������������������������������������������������������������������������������������������������
    * ��������
    * ������������������������������������������������������������������������������������������������������
    */
    /*�����洢Http���͵ı�������*/
    this.ArrayList = function () {
        this.ObjArr = {}; //�б�
        this.Count = 0; // ����
        this.Add = function (key, value) {//����
            this.ObjArr[key] = value;
            this.Count++;
            return true;
        }
        this.Clear = function () {//���
            this.ObjArr = {}; this.Count = 0;
        }
        //��json��ʽ���
        this.toString = function () {
            var newArray = new Array(); //�洢json�ַ���
            var i = 0; for (var i in this.ObjArr) {
                newArray.push("'" + i + "':'" + this.ObjArr[i] + "'");
            }
            return "{" + newArray + "}";
        }
    }
    this.ht = new this.ArrayList();
    /**
    * @deprecated:������Ӧ�ֶ���ֵ���ȴ����͸�������
    * @param FieldName
    * @param FieldValue
    * @return
    */
    this.WebSetMsgByName = function (FieldName, FieldValue) {
        this.ht.Add(FieldName, FieldValue);
    }
	
	this.WebGetMsgByName = function(FieldName) 
	{
		return this.ht.Get(FieldName);
	}

    /*��json��ʽ��������*/
    this.WebSendMessage = function () {
        return this.ht.toString();
    }
    /*@deprecated:�����WebSetMsgByName���õ�ֵ*/
    this.WebClearMessage = function () {
        this.ht.Clear();
    }


    /*�ж����������*/
    this.blnIE = function () {
        //return (window.ActiveXObject != undefined) || (window.ActiveXObject != null) || ("ActiveXObject" in window)
    	if(browser == "chrome")
    		return false;
    	else
    		return true;
    }
     /*�ж��Ƿ���WPS*/
     this.isWPS = function(){
    	 return this.FileType.toUpperCase()  == ".WPS" || this.FileType.toUpperCase()  == ".ET";
     }
    /*
    * �ؼ��汾
    */
    this.Version = function () {
        return this.obj.Version;
    }

    //�Ƿ�����iWebOffice�����ڵĿ������ܡ��ǿؼ��Ĳ���Ӱ��
    this.WebEnableCopy = function (mValue) {
        switch (mValue) {
            case 0:
            case false:
            case "0": this.obj.CopyEnabled = false; break; //����
            case 1:
            case "1":
            case true: this.obj.CopyEnabled = true; break; //�ر�
            default: ; return;
        }
    }

    //ɾ���ļ�
    this.WebDelFile = function (FileName) {
        var fs = this.obj.FileSystem;
        fs.DeleteFile(FileName);
    }

    //����״̬
    this.setEditType = function (type) {
    	try{
        switch (type) {
            case "0": this.VBAProtectDocument(this.getDocType(this.FileType), "123"); break;
            case "1": this.WebShow(false); break;
            case "2": this.WebShow(true); break;
            default: ;
        }
    	}catch(e){
  			return false;
    }
     }
    /**
    ������������������������������������������������������������������������������������������������������
    * End ��������
    * ������������������������������������������������������������������������������������������������������
    */




    /**
    ������������������������������������������������������������������������������������������������������
    * VBAר��
    * ������������������������������������������������������������������������������������������������������
    */
    //��ʾ�ۼ������غۼ�
    this.VBAShowRevisions = function (mValue) {
    	if(this.getDocType(this.FileType)== this.DocType.WORD && (this.obj.ActiveDocument.ProtectionType == "-1" || this.obj.ActiveDocument.ProtectionType == "0")){
        this.obj.ActiveDocument.TrackRevisions = mValue; //��ʾ��Ǻ����ر��
        this.obj.ActiveDocument.ShowRevisions = mValue; //��ʾ�ۼ�������
	    	return true;
    }
    	return false;
     }
    //�����ĵ������ĵ�
    this.VBAProtectDocument = function (docType, password) {
        if (docType == this.DocType.WORD) {//word ����ģʽ
    		 if(this.obj.ActiveDocument.ProtectionType == "-1"){
            alert("112");
			this.obj.ActiveDocument.Protect(3, false, password);
            return true;
        }
    	 }
		 
        if (docType == this.DocType.EXECL) {//word ����ģʽ������ֻ��������1�������İ��Լ������д
    		 if(!this.obj.ActiveDocument.Application.Sheets.Item(1).ProtectContents){ //�жϱ����Ƿ��Ǳ�����
            this.obj.ActiveDocument.Application.Sheets.Item(1).Protect(password);
    		 }
            return true;
        }
    	 return false
    }

    //��������������
    this.VBAUnProtectDocument = function (docType, password) {
        if (docType == this.DocType.WORD) {//word ����ģʽ
            this.obj.ActiveDocument.Unprotect(password); ;
            return;
        }

        if (docType == this.DocType.EXECL) {//word ����ģʽ������ֻ��������1�������İ��Լ������д
            this.obj.ActiveDocument.Application.Sheets.Item(1).Unprotect(password);
            return;
        }
    }


    //������ǩ
    this.VBASetBookmarks = function (vbmName, vbmValue) {
		//alert(vbmName);
		//alert(vbmValue);
    	 try{
        this.obj.ActiveDocument.Bookmarks.Item(BookMarkName).Range.Text = BookMarkValue;
		
		//alert(BookMarkValue);
		
    	 }catch(e){
    		 return false;
    }
     } 
	 
    this.VBAInsertFile_bak = function (Position, FileName) {
        try {
            this.obj.ActiveDocument.Application.Selection.GoTo(-1, 0, 0, Position);
            this.obj.Activate(true);
            this.obj.ActiveDocument.Application.Selection.InsertFile(FileName, "", false, false, false);
            return true;
        } catch (e) {
            return false;
        }
    }
	
	//���ĵ����뵽ָ������ǩλ��  ���ù���������ʵ�֣�
  this.VBAInsertFile = function(Position, FileName)
  {
    this.ConsoleOut("<VBAInsertFile> ��ʼ������ ");
    try {
      var docType = this.getDocType(this.FileType);
      this.ConsoleOut("<VBAInsertFile> �ж��Ƿ���WORD������ ");
      if (docType == this.DocType.WORD) {
        this.ConsoleOut("<VBAInsertFile> �ж���ǩ�Ƿ���ڡ����� ");
        this.obj.Activate(true);
        if (this.obj.ActiveDocument.BookMarks.Exists(Position)) {
          //this.obj.ActiveDocument.Bookmarks(Position).Range.Select(); //����
          setTimeout(this.obj.ActiveDocument.Application.Selection.GoTo(-1, 0, 0, Position),200);
          this.ConsoleOut("<VBAInsertFile> ��ת����ǩָ��λ�á����� ");
        }
        this.obj.Activate(true);
        this.ConsoleOut("<VBAInsertFile> ���ǰ���󡣡��� ");
        this.obj.ActiveDocument.Application.Selection.InsertFile(FileName, "", false, false, false);
        this.ConsoleOut("<VBAInsertFile> ���롣���� "+FileName+"...�ɹ�");
        return true;
      } else {
        this.Status = "��Office�ĵ����޷�ִ�в����ĵ�����";
        this.ConsoleOut("<VBAInsertFile> ��Office�ĵ����޷�ִ�в����ĵ����������� ");
        return false;
      }
    } catch (e) {
      this.Status = "�����ĵ�ʧ�ܣ�����ԭ��" + e.description;
      this.ConsoleOut("�����ĵ�ʧ�ܣ�����ԭ��" + e.description);
      return false;
    }
  }

    //�������кۼ�
    this.WebAcceptAllRevisions = function () {
        try {
            this.obj.Activate(true);
            this.obj.ActiveDocument.Revisions.AcceptAll();
            return this.obj.ActiveDocument.Revisions.Count >= 0 ? true : false;
        } catch (e) {
            return false;
        }
    }
    //����WORD�û���
    this.VBASetUserName = function (UserName) {
    	 try{ 
        this.obj.ActiveDocument.Application.UserName = UserName;
		
    	 }catch(e){
    		 return false;
    }
     }
     //������
     this.ShowField  = function(){
    	try{
    	 this.obj.ActiveDocument.ActiveWindow.View.ShowDrawings = true;
    	// this.obj.ActiveDocument.ActiveWindow.View.ShowFieldCodes = true;
    	}catch(e){
    		return false;
    	}
     }

     //���򱣻�
     this.WebAreaProtect = function(BMarksName)
	 {
		if (this.FileType == ".doc" || this.FileType == ".docx") // word ����ģʽ
		{
			if(this.obj.ActiveDocument.ProtectionType == "-1"){
				var mMarksName = BMarksName.split(",");
				var tag = "";
				for(var i=0;i<=mMarksName.length;i++){
					if (!this.obj.ActiveDocument.BookMarks.Exists(mMarksName[i])) {
						tag += mMarksName[i];
	                    continue;
					}
					var range = this.obj.Range;
					range = this.obj.ActiveDocument.Bookmarks.Item(mMarksName[i]).Range;
					range.Select();
					this.obj.ActiveDocument.bookmarks.Item(mMarksName[i]).range.editors.add(-1); 	// ������wdeditoreveryone=-1
				}

				this.obj.ActiveDocument.Protect(3, false, "123", false, false);				// ������wdAllowOnlyReading=3
				this.obj.ActiveDocument.Application.Selection.MoveLeft(Unit = 1,
						Count = 1);
				this.obj.ActiveDocument.ActiveWindow.View.ShadeEditableRanges = false;		// ȡ��"ͻ����ʾ�ɱ༭����"
				if(tag != ""){
					this.Status = tag + "��ǩ��������";
				}else{
					this.Status = "�����ɹ�����ǩ����ɱ༭";
				}
				return true;
			}else{
				this.Status = "�ĵ��Ա��������������������!";
				return false;
			}
		} else {
			this.Status = "��Office�ĵ����޷�ִ�����򱣻�����!";
			return false;
		}
    }
     //ȡ�����򱣻�
     this.WebAreaUnprotect = function(BMarksName)
	{
		if (this.FileType == ".doc" || this.FileType == ".docx") {
			var mMarksName = BMarksName.split(",");
			for(var i=0;i<=mMarksName.length;i++){
				if (this.obj.ActiveDocument.BookMarks.Exists(mMarksName[i])) 		// �ж��Ƿ���ڸ���ǩ
				{
					try {
						this.obj.ActiveDocument.Unprotect("123");				// �Ᵽ��
						var range = this.obj.Range;
						range = this.obj.ActiveDocument.Bookmarks.Item(mMarksName[i]).Range;
						range.Select();											// ѡ����ǩ����
						this.obj.ActiveDocument.DeleteAllEditableRanges(-1); 	// ȥ��ͻ����ʾ
						this.Status = "��ǩ����" + mMarksName[i] + "���Ա༭";
						return true;
					} catch (e) {
						this.Status = "ִ��ȡ�����򱣻�ʱ���ִ��󣬴���ԭ��" + e.description;
						return false;
					}
				} else {
					this.Status = "�ĵ��в�����<" + mMarksName[i] + ">����ǩ";
					return false;
				}
			}
		} else {
			this.Status = "��Office�ĵ����޷�ִ��ȡ�����򱣻�����!";
			return false;
		}
	}


    /**
    ������������������������������������������������������������������������������������������������������
    * End VBAר��
    * ������������������������������������������������������������������������������������������������������
    */



    /**
    ������������������������������������������������������������������������������������������������������
    * Ƥ��
    * ������������������������������������������������������������������������������������������������������
    */
    this.Skin = function (typeColor) {//���ñ߿����ʾ��ʹ��iWebOffice���ÿ�
        var titleBarColor;
        var menuBarStartColor;
        var menuBarButtonStartColor;
        var menuBarButtonEndColor;
        var menuBarButtonFrameColor;
        var CustomToolbarStartColor;
        switch (typeColor) {
            case "purple": titleBarColor = 0xCC99CC; CustomToolbarStartColor = 0xCC99CC;menuBarStartColor = 0xCC99CC; menuBarButtonStartColor = 0xFFFFFF; menuBarButtonEndColor = 0xAD8DAD; menuBarButtonFrameColor = 0x663366; break;
            case "black": titleBarColor = 0x646464; CustomToolbarStartColor = 0x646464;menuBarStartColor = 0xB7B5B4; menuBarButtonStartColor = 0xF2EAF5; menuBarButtonEndColor = 0xF2EAF5; menuBarButtonFrameColor = 0xF2EAF5; break;
            case "white": titleBarColor = 0xC6C1BE; CustomToolbarStartColor = 0xC6C1BE;menuBarStartColor = 0xF5F3F2; menuBarButtonStartColor = 0xF2EAF5; menuBarButtonEndColor = 0xF2EAF5; menuBarButtonFrameColor = 0xF2EAF5; break;
            case "blue": titleBarColor = 0xD5B69F; CustomToolbarStartColor = 0xD5B69F;menuBarStartColor = 0xFCF3EF; menuBarButtonStartColor = 0xF2EAF5; menuBarButtonEndColor = 0xF2EAF5; menuBarButtonFrameColor = 0xF2EAF5; break;
            case "yellow": titleBarColor = 0x00CCFF; CustomToolbarStartColor = 0x00CCFF;menuBarStartColor = 0x6AB9FF; menuBarButtonStartColor = 0xF2EAF5; menuBarButtonEndColor = 0xF2EAF5; menuBarButtonFrameColor = 0xF2EAF5; break;
        }
        var style = this.obj.Style;
        style.TitleBarColor = titleBarColor;
        style.TitleBarTextColor = 0x000000;
        style.MenuBarStartColor = menuBarStartColor;
        style.MenuBarEndColor = 0xFFFFFF;
        style.MenuBarTextColor = 0x000000;
        style.MenuBarHighlightTextColor = 0x000000;
        style.MenuBarButtonStartColor = menuBarButtonStartColor;
        style.MenuBarButtonEndColor = menuBarButtonEndColor;
        style.MenuBarButtonFrameColor = menuBarButtonFrameColor;
        style.CustomToolbarStartColor=CustomToolbarStartColor;
        style.Invalidate();

    }
    this.setColor = function (typeColor) {   //���ñ߿���ʾ
    	var titleBarColor;
        var menuBarStartColor;
        var menuBarButtonStartColor;
        var menuBarButtonEndColor;
        var menuBarButtonFrameColor;
        var CustomToolbarStartColor;
        switch (typeColor) {
            case "purple": titleBarColor = 0xCC99CC; CustomToolbarStartColor = 0xCC99CC;menuBarStartColor = 0xCC99CC; menuBarButtonStartColor = 0xFFFFFF; menuBarButtonEndColor = 0xAD8DAD; menuBarButtonFrameColor = 0x663366; break;
            case "black": titleBarColor = 0x646464; CustomToolbarStartColor = 0x646464;menuBarStartColor = 0xB7B5B4; menuBarButtonStartColor = 0xF2EAF5; menuBarButtonEndColor = 0xF2EAF5; menuBarButtonFrameColor = 0xF2EAF5; break;
            case "white": titleBarColor = 0xC6C1BE; CustomToolbarStartColor = 0xC6C1BE;menuBarStartColor = 0xF5F3F2; menuBarButtonStartColor = 0xF2EAF5; menuBarButtonEndColor = 0xF2EAF5; menuBarButtonFrameColor = 0xF2EAF5; break;
            case "blue": titleBarColor = 0xD5B69F; CustomToolbarStartColor = 0xD5B69F;menuBarStartColor = 0xFCF3EF; menuBarButtonStartColor = 0xF2EAF5; menuBarButtonEndColor = 0xF2EAF5; menuBarButtonFrameColor = 0xF2EAF5; break;
            case "yellow": titleBarColor = 0x00CCFF; CustomToolbarStartColor = 0x00CCFF;menuBarStartColor = 0x6AB9FF; menuBarButtonStartColor = 0xF2EAF5; menuBarButtonEndColor = 0xF2EAF5; menuBarButtonFrameColor = 0xF2EAF5; break;
        }
        var style = this.obj.Style;
        style.TitleBarColor = titleBarColor;
        style.TitleBarTextColor = 0x000000;
        style.MenuBarStartColor = menuBarStartColor;
        style.MenuBarEndColor = 0xFFFFFF;
        style.MenuBarTextColor = 0x000000;
        style.MenuBarHighlightTextColor = 0x000000;
        style.MenuBarButtonStartColor = menuBarButtonStartColor;
        style.MenuBarButtonEndColor = menuBarButtonEndColor;
        style.MenuBarButtonFrameColor = menuBarButtonFrameColor;
        style.CustomToolbarStartColor=CustomToolbarStartColor;
        style.Invalidate();
    }
    /**
    ������������������������������������������������������������������������������������������������������
    * End Ƥ��
    * ������������������������������������������������������������������������������������������������������
    */


    /**
    ������������������������������������������������������������������������������������������������������
    * ��дǩ������
    * ������������������������������������������������������������������������������������������������������
    */
    //������дǩ��������
    this.AddToolbar=function() {
    	//this.obj.Style.ShowCustomToolbar=true;
    	this.obj.Handwritting.Show = !this.obj.Handwritting.Show;
    	var URL = this.WebUrl.substring(0, this.WebUrl.lastIndexOf("/"));
	    var customtoolbar = this.obj.CustomToolbar;
		customtoolbar.AddToolButton(301,"��дǩ��",URL+"/HandWrite/"+"shouxie24.png", "��дǩ��",0);
		customtoolbar.AddToolButton(302,"ֹͣ��д",URL+"/HandWrite/"+"tingzhi24.png","ֹͣ��д",0);
		customtoolbar.AddToolButton(303,"����ǩ��",URL+"/HandWrite/"+"wenzi24.png","����ǩ��",0);
		customtoolbar.AddToolButton(300,"-","","",1);
		customtoolbar.AddToolButton(304,"ͼ��ǩ��",URL+"/HandWrite/"+"tuxing24.png","ͼ��ǩ��",0);
		customtoolbar.AddToolButton(305,"ȡ����һ��ǩ��",URL+"/HandWrite/"+"quxiao24.png","ȡ����һ��ǩ��",0);
		customtoolbar.AddToolButton(306,"��ʾ�û�ǩ��",URL+"/HandWrite/"+"xianshi24.png","��ʾ�û�ǩ��",0);
	}
	
	//������дǩ��������
    this.VisibleToolsButton=function() {
    	//this.obj.Style.ShowCustomToolbar=true;
    	this.obj.Handwritting.Show = !this.obj.Handwritting.Show;
    	var URL = this.WebUrl.substring(0, this.WebUrl.lastIndexOf("/"));
	    var customtoolbar = this.obj.CustomToolbar;
		customtoolbar.DisableToolsButton("��дǩ��",1);
		customtoolbar.DisableToolsButton("ֹͣ��д",1);
		customtoolbar.VisibleToolsButton("����ǩ��",1);
		customtoolbar.AddToolButton(300,"-","","",1);
		customtoolbar.VisibleToolsButton("ͼ��ǩ��",0);
		customtoolbar.VisibleToolsButton("ȡ����һ��ǩ��",0);
		customtoolbar.VisibleToolsButton("��ʾ�û�ǩ��",0);
		
		this.obj.Style.Invalidate();
	}

  //��дǩ��
    this.HandWriting = function(penColor,penWidth){
    	var handwritting = this.obj.Handwritting;
		var handsetting = handwritting.DrawingSetting;
		handsetting.PenThicker = penWidth;
		handsetting.PenColor = penColor;
		handwritting.AnnotateDraw();
		this.ShowMenuBar(false);//ǩ��ʱ���ز˵���
		this.ShowToolBars(false);//ǩ��ʱ���ع�����


    }
    //ֹͣ��дǩ��
    this.StopHandWriting = function(){
    	var handwritting = this.obj.Handwritting;
			handwritting.StopAnnotate();
			this.ShowMenuBar(true);//ֹͣǩ��ʱ��ʾ�˵���
			this.ShowToolBars(true);//ֹͣǩ��ʱ��ʾ������
    }
    //����ǩ��
    this.TextWriting = function(){
    	var handwritting = this.obj.Handwritting;
		var textsetting = handwritting.TextSetting;
		textsetting.TextSize = 32;
		textsetting.TextColor = 0xbb00ff;
		textsetting.FontName = "����";
		handwritting.AnnotateText();
		this.ShowMenuBar(false);//ǩ��ʱ���ز˵���
		this.ShowToolBars(false);//ǩ��ʱ���ع�����

    }
    //ͼ��ǩ��
    this.ShapeWriting = function(){
    	var handwritting = this.obj.Handwritting;
		var shapesetting = handwritting.ShapeSetting;
		shapesetting.ShapeType = 0;
		shapesetting.BackgroundColor = 0xffffff;
		shapesetting.BorderColor = 0xff0000;
		shapesetting.BorderWidth = 6;
		handwritting.AnnotateShape();
		this.ShowMenuBar(false);//ǩ��ʱ���ز˵���
		this.ShowToolBars(false);//ǩ��ʱ���ع�����
    }
    //ȡ����һ��ǩ��
    this.RemoveLastWriting = function(){
    	var handwritting = this.obj.Handwritting;
		handwritting.RemoveLast();
    }
    //��ʾĳ�û���ǩ��
    this.ShowWritingUser = function(bVal,username){
    	var strxml = this.obj.GetAnnotations();
    	var json = eval('(' + strxml + ')');
		if (username != "" && username != null && username!=undefined) {
			for(var i=0;i<json.Annotations.length;i++)
			{
				if(json.Annotations[i].Annotation.User != username) {
					var id = json.Annotations[i].Annotation.ID;
					this.obj.GetAnnotationByID(id).Visible = bVal;
				}
			}
		}else {
			for(var i=0;i<json.Annotations.length;i++)
			{
				var id = json.Annotations[i].Annotation.ID;
				this.obj.GetAnnotationByID(id).Visible = bVal;
			}
		}
    }
    //��ʾ/������дǩ��������
    this.ShowCustomToolbar = function(bVal){
    	this.obj.Style.ShowCustomToolbar=bVal;
    	//if(bVal==true) this.obj.Style.CustomToolbarStartColor=0xDDA0DD; //����ǩ����������ɫ
    }
    /**
    ������������������������������������������������������������������������������������������������������
    * ��дǩ������
    * ������������������������������������������������������������������������������������������������������
    */

    /**
    ������������������������������������������������������������������������������������������������������
    * ��չ����
    * ������������������������������������������������������������������������������������������������������

    */
    //����ΪPDF
    this.WebSavePDF = function(){
    	var httpclient = this.obj.Http; //����http����
        httpclient.Clear();
	   	this.WebSetMsgByName("RECORDID",this.RecordID);
	   	this.WebSetMsgByName("OPTION","SAVEPDF");
	   	this.WebSetMsgByName("FILENAME",this.RecordID + ".pdf");//����FileName
	   	this.SaveAsPdf(this.getFilePath()+this.RecordID + ".pdf");
		//alert(this.getFilePath()+this.RecordID + ".pdf");
	   	if(this.SAVEFILE(httpclient,this.getFilePath()+this.RecordID + ".pdf")){
   		 this.Status = "�����ļ��ɹ�";
   		 this.obj.FuncExtModule.alert("����PDF�ɹ�!");
   		 return true;
	   	}
   	 this.Status = "�����ļ�ʧ��";
   	 return false;
   }



    this.SaveAsPdf = function(FilePath){
    	//var FilePath=this.getFilePath() + this.RecordID + ".pdf";
    	if ((this.FileType  == ".doc") || (this.FileType  == ".docx") || (this.FileType  == ".wps"))
		  {
		  	try
				{
		  		//this.obj.ActiveDocument.ExportAsFixedFormat(FilePath, 17, false, 0, 0, 1, 1, 0, true, true, 0, true, true, true);
				
				//���Office360ǩ������ΪPDF��pdf�ĵ���ӡ����ʾΪ�ڵ�
				//this.obj.ActiveDocument.ExportAsFixedFormat(FilePath, 17,false,0,0,0,0,0,false,true,0,true,true,false);
				this.obj.ActiveDocument.ExportAsFixedFormat(FilePath, 17,false, 0,0,0,0,0, true, true,2,true,true,false);
				}
				catch (e)
				{
					this.Status = e.description;
					return false;
		  	}
				return true;
		  }
	  }

    //����Ϊhtml
    this.SaveAsHtml = function(FilePath){
    	if ((this.FileType  == ".doc") || (this.FileType  == ".docx") || (this.FileType  == ".wps"))
  	  {
  	  	try
  			{
  	  			var ret = this.obj.ActiveDocument.SaveAs(FilePath,8,false,"",false,"",false,false,false,false,false,0);
  			   	this.obj.ActiveDocument.Application.ActiveWindow.View.type = 3;//3��ҳ����ͼ
  			}
  			catch (e)
  			{
  				this.Status = e.description;
  				return false;
  	  	}
  	  	return true;;
  	  	}
    }

    this.WebSaveHtml = function(){
	  	if(this.SaveAsHtml("C:\\"+this.RecordID + ".html"))
	  	{
		  	alert("����Html�ɹ�!\n����·��:  "+"C:\\"+this.RecordID + ".html");
			
			var htmlpath = "C:\\"+this.RecordID + ".html";
		  
		  //alert(this.obj.GetHTML(htmlpath));
	  	}
    }

	//ͼƬ��
	this.WebOpenSignature = function ()
    {
    	//alert("111");
		var funExt = this.obj.FuncExtModule;
    	funExt.ServerType = 1;
    	funExt.SetDocument(this.obj.ActiveDocument);
    	funExt.WebUrl = this.WebUrl;
    	funExt.WebOpenSignature();
    }

	//FuncExtModule�ӿڲ���
	this.FuncExtModule = function()
	{
		alert(this.obj.FuncExtModule);
		alert('��ǰ�ؼ��汾Ϊ��'+this.obj.FuncExtModule.Version());
	}

	//ִ�к�
    this.WebRunMacro = function(MarcroName,MacroValue){
    	try{
    		   var VBAStr =  MacroValue;
    		   var VBCom;
    		   VBCom = this.obj.ActiveDocument.VBProject.VBComponents.Add(1);
    		   VBCom.CodeModule.AddFromString(VBAStr);
    		   this.obj.ActiveDocument.Application.Run(MarcroName);
    		   return true;
    	     	}catch(e){
    	     		return false;
    	     	}
     }

	 
	this.WebDownloadFile_int = function(id,fn) {
    	this.Status = '';
    	var httpclient = this.obj.Http; //����http����
      httpclient.Clear();
      this.WebSetMsgByName("USERNAME", this.UserName); 	//����UserName
      this.WebSetMsgByName("FILENAME", fn); 						//����FileName
      this.WebSetMsgByName("FILETYPE", this.FileType); 	//����FileType
      //this.WebSetMsgByName("RECORDID", this.RecordID); 	//����RecordID
	  this.WebSetMsgByName("RECORDID", id); 	//����RecordID
      this.WebSetMsgByName("OPTION", "LOADFILE");     	//��������LOADFILE
      httpclient.AddForm("FormData", this.WebSendMessage()); //�������Զ���json �����ʽ��
      this.WebClearMessage();                         //�������WebSetMsgByName����

      httpclient.ShowProgressUI = true;//��ʾ������
      if (httpclient.Open(this.HttpMethod.Post, this.WebUrl, false)) {//�������ͬ����ʽ���ĵ�����Ҫ����ֵ
      	if (httpclient.Send()) {
        	if (httpclient.GetResponseHeader("MsgError") == "404") { //�жϷ������Ƿ�����ļ�
						this.Status = '�ĵ���' + fn + '������ʧ�ܣ���ȷ�ϸ��ĵ��ڷ��������Ƿ����';
          	httpclient.Clear();
            return false;
          }
          httpclient.Clear();
          if (this.hiddenSaveLocal(httpclient, this, false, false, fn)) {//���سɹ�ʱ
          	this.Status = '�ĵ����سɹ�';
          	return true;
		 			}
		 			else {
		 				this.Status = '�ĵ�����ʧ��';
          	return false;
		 			}
    		}
    	}
    } 
	
	//�����ĵ�
    this.DownloadToFileEx = function (DownFileName, SavePathName) {   //�Լ�������
        var httpclient = this.obj.Http;
        var URL = this.WebUrl.substring(0, this.WebUrl.lastIndexOf("/"));
        //httpclient.ShowProgressUI = true;//���ؽ�����
        if (httpclient.Open(this.HttpMethod.Get, URL + "/Document/" + DownFileName, false)) {//ָ������ģ�������
			if (httpclient.Send()) {
                if (httpclient.Status == 200) {
                	httpclient.ResponseSaveToFile(SavePathName + DownFileName);
                	httpclient.Clear();
                    return true;
                }
            }
        }
        httpclient.Close();
        return false;
    }
	
	this.addHeaderPic = function(text,msg){
		//����ʱʹ���Լ��ĵ�ַ���ط�����ͼƬ
		var ImagePath = this.DownFilePath();
		var ImageName = text + ".jpg";
		this.DownloadToFileEx(ImageName,ImagePath);  //�ڲ�����ʱʹ�øýӿ�
		if(this.blnIE())
		{
			var intPageTotal = this.WebObject.ActiveDocument.Application.ActiveDocument.BuiltInDocumentProperties(14);
		}
		else
		{
			var intPageTotal = this.WebObject.ActiveDocument.Application.ActiveDocument.BuiltInDocumentProperties.Item(14).Value();
		}
		intPage = parseInt(intPageTotal);
		var selection =WebOffice.WebObject.ActiveDocument.Application.Selection;
		if(WebOffice.WebObject.ActiveDocument.ProtectionType == "-1")
		{
			for(var i=1;i<=intPage;i++) {
				selection.GoTo(What = 1, Which = 1, Count = i);
				WebOffice.WebObject.ActiveDocument.ActiveWindow.ActivePane.View.SeekView = 9; //wdSeekCurrentPageHeader
				selection.ClearFormatting()
				WebOffice.WebObject.ActiveDocument.Shapes.AddTextEffect(0, msg, '����', 8, false, false, 80, 30);
				selection.HeaderFooter.Shapes.AddPicture(ImagePath + ImageName,true,true,380, -20, 53, 53);
				WebOffice.WebObject.ActiveDocument.ActiveWindow.ActivePane.View.SeekView = 0;
			}
		}
	}
	 
    this.WebDownloadFile = function(fn) {
    	this.Status = '';
    	var httpclient = this.obj.Http; //����http����
      httpclient.Clear();
      this.WebSetMsgByName("USERNAME", this.UserName); 	//����UserName
      this.WebSetMsgByName("FILENAME", fn); 						//����FileName
      this.WebSetMsgByName("FILETYPE", this.FileType); 	//����FileType
      this.WebSetMsgByName("RECORDID", this.RecordID); 	//����RecordID
      this.WebSetMsgByName("OPTION", "LOADFILE");     	//��������LOADFILE
      httpclient.AddForm("FormData", this.WebSendMessage()); //�������Զ���json �����ʽ��
      this.WebClearMessage();                         //�������WebSetMsgByName����

      httpclient.ShowProgressUI = true;//��ʾ������
      if (httpclient.Open(this.HttpMethod.Post, this.WebUrl, false)) {//�������ͬ����ʽ���ĵ�����Ҫ����ֵ
      	if (httpclient.Send()) {
        	if (httpclient.GetResponseHeader("MsgError") == "404") { //�жϷ������Ƿ�����ļ�
						this.Status = '�ĵ���' + fn + '������ʧ�ܣ���ȷ�ϸ��ĵ��ڷ��������Ƿ����';
          	httpclient.Clear();
            return false;
          }
          httpclient.Clear();
          if (this.hiddenSaveLocal(httpclient, this, false, false, fn)) {//���سɹ�ʱ
          	this.Status = '�ĵ����سɹ�';
          	return true;
		 			}
		 			else {
		 				this.Status = '�ĵ�����ʧ��';
          	return false;
		 			}
    		}
    	}
    }
	
	this.WebDocumentCompare = function(ID1,FileName1, ID2,FileName2){
    	//�뵱ǰ�򿪵��ĵ����жԱ�
    	this.Status = '';
    	var fs = this.obj.FileSystem; //����file����
    	var filePath = fs.GetSpecialFolderPath(0x1a) + this.DOWN;
    	var saveFilePath = filePath + Math.round(Math.random() * 100000000) + '.doc';
    	if ((FileName1 == null) || (FileName1 == '')) {
    		if ((FileName2 == null) || (FileName2 === '')) {
    			this.Status = '��FileName2������Ϊ��!';
    			return false;
    		}
    		else {
    			//��ʼ����FileName2
    			if (this.WebDownloadFile_int(ID2,FileName2)) {
    				FileName1 = this.FileName;
    				this.WebSaveLocalFile(filePath + FileName1);
    				this.WebClose();
    				var bRet = this.obj.FuncExtModule.WebDocumentCompare(filePath + FileName1, filePath + FileName2, saveFilePath);
        		if (bRet == true) {
            	this.obj.Open(saveFilePath);
            	this.obj.ActiveDocument.Application.ActiveWindow.View.type = 3;
            	this.obj.ActiveDocument.Application.ActiveWindow.View.SplitSpecial = 20;
            	return true;
        		}
        		else {
        			this.Status = '�ĵ��Ա�ʧ��,��ȷ�ϴ��Աȵ��ĵ��Ƿ��ܹ�������!';
        			return false;
        		}
    			}
    			else {
    				this.Status = '�ļ���' + FileName2 + '������ʧ�ܣ����ĵ������ڷ�����������!';
    				return false;
    			}
    		}
    	}
    	//��ָ���ĺ�̨�����ĵ����жԱ�
    	else{
    		if ((FileName2 == null) || (FileName2 == '')) {
    			this.Status = '��FileName2������Ϊ��!';
    			return false;
    		}
    		else {
    			//��ʼ�ֱ�����ָ���������ļ�
    			if (this.WebDownloadFile_int(ID1,FileName1)) {
    				if ((this.WebDownloadFile_int(ID2,FileName2))) {
    					this.WebClose();
    					var bRet = this.obj.FuncExtModule.WebDocumentCompare(filePath + FileName1, filePath + FileName2, saveFilePath);
        			if (bRet == true) {
            		this.obj.Open(saveFilePath);
            		this.obj.ActiveDocument.Application.ActiveWindow.View.type = 3 //
            		this.obj.ActiveDocument.Application.ActiveWindow.View.SplitSpecial = 20;
            		return true;
        			}
        			else {
        				this.Status = '�ĵ��Ա�ʧ��,��ȷ�ϴ��Աȵ��ĵ��Ƿ��ܹ�������!';
        				return false;
        			}
    				}
    				else {
    					this.Status = '�ļ���' + FileName2 + '������ʧ�ܣ����ĵ������ڷ�����������!';
    					return false;
    				}
    			}
    			else {
    				this.Status = '�ļ���' + FileName1 + '������ʧ�ܣ����ĵ������ڷ�����������!';
    				return false;
    			}
    		}
    	}
    }
	
    this.WebDocumentCompareEx = function(FileName1, FileName2){
    	//�뵱ǰ�򿪵��ĵ����жԱ�
    	this.Status = '';
    	var fs = this.obj.FileSystem; //����file����
    	var filePath = fs.GetSpecialFolderPath(0x1a) + this.DOWN;
    	var saveFilePath = filePath + Math.round(Math.random() * 100000000) + '.doc';
    	if ((FileName1 == null) || (FileName1 == '')) {
    		if ((FileName2 == null) || (FileName2 === '')) {
    			this.Status = '��FileName2������Ϊ��!';
    			return false;
    		}
    		else {
    			//��ʼ����FileName2
    			if (this.WebDownloadFile(FileName2)) {
    				FileName1 = this.FileName;
    				this.WebSaveLocalFile(filePath + FileName1);
    				this.WebClose();
    				var bRet = this.obj.FuncExtModule.WebDocumentCompare(filePath + FileName1, filePath + FileName2, saveFilePath);
        		if (bRet == true) {
            	this.obj.Open(saveFilePath);
            	this.obj.ActiveDocument.Application.ActiveWindow.View.type = 3;
            	this.obj.ActiveDocument.Application.ActiveWindow.View.SplitSpecial = 20;
            	return true;
        		}
        		else {
        			this.Status = '�ĵ��Ա�ʧ��,��ȷ�ϴ��Աȵ��ĵ��Ƿ��ܹ�������!';
        			return false;
        		}
    			}
    			else {
    				this.Status = '�ļ���' + FileName2 + '������ʧ�ܣ����ĵ������ڷ�����������!';
    				return false;
    			}
    		}
    	}
    	//��ָ���ĺ�̨�����ĵ����жԱ�
    	else{
    		if ((FileName2 == null) || (FileName2 == '')) {
    			this.Status = '��FileName2������Ϊ��!';
    			return false;
    		}
    		else {
    			//��ʼ�ֱ�����ָ���������ļ�
    			if (this.WebDownloadFile(FileName1)) {
    				if ((this.WebDownloadFile(FileName2))) {
    					this.WebClose();
    					var bRet = this.obj.FuncExtModule.WebDocumentCompare(filePath + FileName1, filePath + FileName2, saveFilePath);
        			if (bRet == true) {
            		this.obj.Open(saveFilePath);
            		this.obj.ActiveDocument.Application.ActiveWindow.View.type = 3 //
            		this.obj.ActiveDocument.Application.ActiveWindow.View.SplitSpecial = 20;
            		return true;
        			}
        			else {
        				this.Status = '�ĵ��Ա�ʧ��,��ȷ�ϴ��Աȵ��ĵ��Ƿ��ܹ�������!';
        				return false;
        			}
    				}
    				else {
    					this.Status = '�ļ���' + FileName2 + '������ʧ�ܣ����ĵ������ڷ�����������!';
    					return false;
    				}
    			}
    			else {
    				this.Status = '�ļ���' + FileName1 + '������ʧ�ܣ����ĵ������ڷ�����������!';
    				return false;
    			}
    		}
    	}
    }
	
	// ����Rounded�ۼ�
    this.ClearMarks = function()
    {
    	//this.obj.ActiveDocument.Shapes(1).Name;
    	var shapeCount = this.obj.ActiveDocument.Shapes.Count;
    	for(var i=shapeCount; i>=1; i--)
    	{
    		var shapeName = this.obj.ActiveDocument.Shapes(i).Name;
    		if( shapeName.indexOf("Rounded Rectangle") != -1 )
    		{
    			this.obj.ActiveDocument.Shapes(i).Delete();	
    		}
    	}
    	
    }
	
	
	/* �����õĴ�ӡ�������д�ӡ */
	this.PrintByCopies = function(Copies, Show) {
		var mAPIObj;
    	var mApiName;
    	var mAppName;
		//this.obj.FuncExtModule.alert("1234");
		//this.obj.FuncExtModule.alert(this.obj.ActiveDocument.Application.Name);
    	mAppName = this.obj.ActiveDocument.Application.Name;
		//this.obj.FuncExtModule.alert(mAppName);
    	if(mAppName == "Microsoft Word"){
    		mAPIObj = this.obj.ActiveDocument.Application.Dialogs.Item(88);
    		if(Show){
    			mAPIObj.NumCopies = Copies;
    			if(mAPIObj.Display == -1){
    				mAPIObj.Execute;
    				this.Status = "��ӡ�ɹ�";
    				return true;
    			}else{
    				this.Status = "���ô�ӡ������ʧ��";
    				return false;
    			}
    		}else{
    			//this.obj.FuncExtModule.alert(Copies);
				//mAPIObj.NumCopies = Copies;
				//this.obj.FuncExtModule.alert("222");
    			mAPIObj.Execute();
    			this.Status = "��ӡ�ɹ�";
    			return true;
    		}
    	}else{
    		this.Status = "�ĵ�����word����";
    		return false;
    	}
	}
	
    /**
    ������������������������������������������������������������������������������������������������������
    * ��չ����
    * ������������������������������������������������������������������������������������������������������
    */
	
	//�ƴ�Ѷ�ɶ��Ʋ���βע, contentText��������, endnotesTextβע��Ϣ
	this.WebSetEndnotes = function(contentText, endnotesText){
		var selection = this.WebObject.ActiveDocument.Application.Selection;
		selection.Text = contentText;
		var endnoteOptions = selection.EndnoteOptions;
        endnoteOptions.Location = 1;
        endnoteOptions.NumberingRule = 0;
        endnoteOptions.StartingNumber = 1;
        endnoteOptions.NumberStyle = 28;
        
        selection.Endnotes.Add(selection.Range, "", endnotesText);
	}
	
    this.AddZoneDomain = function(domain)
    {
    	 var WshShell=new ActiveXObject("WScript.Shell");
    	 WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\" + domain, "");
    	 WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\" + domain + "\\www","");
    	 WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\" + domain + "\\www\\http","2","REG_DWORD");
    }
    this.AddZoneRange = function(range)
    {
    	 var WshShell=new ActiveXObject("WScript.Shell");
    	 
    	 WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range100\\","");
    	 WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range100\\http","2","REG_DWORD");
    	 WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range100\\:Range",range);
    }  
    
    this.IsItHasTrusted = function(version, app)
	{
		var ret = this.regRead("HKCU\\Software\\Microsoft\\Office\\" + version + "\\" + app + "\\Security\\Trusted Locations\\");  
		if(ret != null)
			return true;
		else
			return false;
	}
	this.SetTrustedLocation = function (version, app, location)
	{
		var ret = this.regWrite("HKCU\\Software\\Microsoft\\Office\\" + version + "\\" + app + "\\Security\\Trusted Locations\\Location99\\Path",location);  
		return ret;
	}
	this.DeleteTrustedLocation = function(version, app)
	{
		var ret = this.regDelete("HKCU\\Software\\Microsoft\\Office\\" + version + "\\" + app + "\\Security\\Trusted Locations\\Location99\\");  
		return ret;
	}
	
	/**
	*�ж��ĵ��Ƿ��޸ģ����ĵ����Ȼ�ȡ�ĵ�����,�������0, ����ʱ�������1���ж��ĵ��Ƿ��޸ģ���ʾ�Ƿ�Ҫ����
	*/
	this.IsModify = function(value)
	{
		//alert(value);
		var ret = this.obj.IsModify(value);
		
		return ret;
	}
	
	/** 
	 * ע����༭������װ��ע����Ĳ��� 
	 */  

	/** ������Ϊ strName ��ע�����ֵ�� 
	 * @param strName Ҫ��ȡ�ļ���ֵ����� strName �Է�б�� (\) �����������������ؼ���������ֵ 
	 * @return ��Ϊ strName ��ע�����ֵ 
	 */  
	this.regRead = function (strName)
	{  
		var WshShell= new ActiveXObject("WScript.Shell");

	    var val = null;  
	    try {  
	        val = WshShell.regRead(strName);
	    } catch (e) {  
	        //alert(e.message);  
	    }

	    return val;  
	}  
	   
	/** ���� strName ָ����ע�����ֵ 
	 * @param strName Ҫд�ļ���ֵ������.��� strName �Է�б�� (\) �����������������ؼ���������ֵ 
	 * @param anyValue Ҫд�����ע���ֵ�е�ֵ 
	 * @param strType ��ѡ�Ҫ���浽ע����е�ֵ����������REG_SZ��REG_EXPAND_SZ��REG_DWORD��REG_BINARY 
	 */  
	this.regWrite = function (strName,anyValue,strType)
	{
		var WshShell= new ActiveXObject("WScript.Shell");

	    if(strType == null)  
	        strType = "REG_SZ";  
	    WshShell.regWrite(strName,anyValue,strType);  
	}  
	   
	/** ��ע�����ɾ�� strName ָ���ļ���ֵ�� 
	 * @param strName Ҫɾ���ļ���ֵ�����֡���� strName �Է�б�� (\) ��������������ɾ������������ֵ 
	 */  
	this.regDelete = function (strName)
	{  
		var WshShell= new ActiveXObject("WScript.Shell");
		WshShell.regDelete(strName);  
	}  
	////////////////ע����༭��end//////////////////////
	
	/**
	 * 设置控件皮肤	（该功能已完整实现）
	 * @param {*} titleBarColor 控件标题栏颜色
	 * @param {*} menuBarStartColor 自定义菜单开始颜色
	 * @param {*} menuBarButtonStartColor 自定义工具栏按钮开始颜色
	 * @param {*} menuBarButtonEndColor 自定义工具栏按钮结束颜色
	 * @param {*} menuBarButtonFrameColor 自定义工具栏按钮边框颜色
	 * @param {*} CustomToolbarStartColor 自定义工具栏开始颜色
	 * @param {*} TitleBarTextColor 控件标题栏文本颜色
	 * @returns 
	 */
	this.WebSetSkin = function(titleBarColor,
			menuBarStartColor,
			menuBarButtonStartColor,
			menuBarButtonEndColor,
			menuBarButtonFrameColor,
			CustomToolbarStartColor, TitleBarTextColor) {
		this.Status = '';
		var style = this.obj.Style;
		try {
			style.TitleBarColor = titleBarColor;
			if ((TitleBarTextColor == undefined) || (TitleBarTextColor == '')) // 设置默认标题文字颜色
			{
				style.TitleBarTextColor = 0x000000; // 黑色
			} else {
				style.TitleBarTextColor = TitleBarTextColor;
			}
		    titleBarColor = 0xf2f9ff;
		    CustomToolbarStartColor = 0xf2f9ff;
		    menuBarStartColor = 0xf2f9ff;
		    menuBarButtonStartColor = 0x90cbf4;
		    menuBarButtonEndColor = 0x90cbf4;
		    menuBarButtonFrameColor = 0x90cbf4;
			style.MenuBarStartColor = menuBarStartColor;
			style.MenuBarEndColor = 0xFFFFFF;
			style.MenuBarTextColor = 0x000000;
			style.MenuBarHighlightTextColor = 0x000000;
			style.MenuBarButtonStartColor = menuBarButtonStartColor;
			style.MenuBarButtonEndColor = menuBarButtonEndColor;
			style.MenuBarButtonFrameColor = menuBarButtonFrameColor;
			style.CustomToolbarStartColor = CustomToolbarStartColor;
			style.CustomToolbarEndColor = CustomToolbarStartColor;
			style.Invalidate();
			return true;
		} catch (e) {
			this.Status = '皮肤设置错误，错误信息为：' + e.description;
			return false;
		}
	}


}

function createOffice(mFileType, mUserName) {
	try {
		//��ʼ��ֵ
		var mRecordID = "";
		WebOffice.setObj(document.getElementById('WebOffice2015'));             //��2015����ֵ
		//WebOffice.WebUrl = getIpPath() + CMS_END_CTX + "/cms/office/loadFile/";  //WebUrl:ϵͳ������·������������ļ������������籣�桢���ĵ�����Ҫ�ļ�
		WebOffice.WebUrl = "http://10.200.100.21:8080/iWebOffice2015Demo/OfficeServer";//����ʱʹ�øĵ�ַ
		WebOffice.RecordID = mRecordID;                                         //RecordID:���ĵ���¼���
		WebOffice.FileName = (new Date().getTime()).toString() + mFileType;                             //FileName:�ĵ�����
		WebOffice.FileType = mFileType;                                         //FileType:�ĵ�����  .doc  .xls
		WebOffice.UserName = mUserName;
		//UserName:�����û������ۼ�������Ҫ
		WebOffice.AppendMenu("1", "�򿪱����ļ�(&L)");                           //��θ��ļ��˵�����
		WebOffice.AppendMenu("2", "���汾���ļ�(&S)");
		WebOffice.AppendMenu("3", "-");
		WebOffice.AppendMenu("4", "��ӡԤ��(&C)");
		WebOffice.AppendMenu("5", "�˳���ӡԤ��(&E)");
		WebOffice.AddCustomMenu();                                              //һ���Զ�����Ӱ������β˵�
		WebOffice.WebSetSkin('purple');                                               //����Ƥ��
		WebOffice.HookEnabled();
		WebOffice.SetCaption();
		WebOffice.SetUser(mUserName);
		if (browser == "chrome"){
			//getCookie(WebOffice.WebUrl)
		}
		if (WebOffice.CreateFile()) {                                           //�򿪸��ĵ�    ����OfficeServer  �����ĵ�OPTION="LOADFILE"
			WebOffice.setEditType("1");                                         //EditType:�༭����  ��ʽһ   WebOpen֮��
			WebOffice.VBASetUserName(WebOffice.UserName);                       //�����û���
			getEditVersion();                                                   //�ж��Ƿ�������office             //���ĵ�ʱ��ʾ��дǩ��������
			WebOffice.ShowCustomToolbar(false);                                 //������дǩ��������
			StatusMsg(WebOffice.Status);
		}
	} catch (e) {
		alert(e);
	}

}
//����Ҫ�򿪵��ĵ���Ϣ ��ˮӡʹ�õ������ �ļ���
function loadOffice(recordID, fileName, fileType, userName, editType,tempFileExt) {
	alert(333);
	try {
		alert(344);
		//WebOffice.WebUrl = getIpPath() + CMS_END_CTX + "/cms/office/loadFile/";  //WebUrl:ϵͳ������·������������ļ������������籣�桢���ĵ�����Ҫ�ļ�
		WebOffice.WebUrl = "http://10.200.100.21:8080/iWebOffice2015Demo/OfficeServer";//����ʱʹ�øĵ�ַ
		WebOffice.RecordID = recordID;                                        //RecordID:���ĵ���¼���
		WebOffice.FileName = recordID+fileType;                                        //FileName:�ĵ�����
		WebOffice.fileNewName = fileName;                                        //FileName:�ĵ�����
		WebOffice.FileType = fileType;                                        //FileType:�ĵ�����  .doc  .xls
		WebOffice.UserName = userName;                                        //UserName:�����û������ۼ�������Ҫ
		WebOffice.AppendMenu("1", "�򿪱����ļ�(&L)");                        //��θ��ļ��˵�����
		WebOffice.AppendMenu("2", "���汾���ļ�(&S)");
		WebOffice.AppendMenu("3", "-");
		WebOffice.AppendMenu("4", "��ӡԤ��(&C)");
		WebOffice.AppendMenu("5", "�˳���ӡԤ��(&E)");
		WebOffice.AddCustomMenu();                                          //һ���Զ�����Ӱ������β˵�
		WebOffice.WebSetSkin('purple');                                            //����Ƥ��
		WebOffice.HookEnabled();
		WebOffice.SetCaption();
		WebOffice.SetUser(userName);
		if (browser == "chrome"){
			getCookie(WebOffice.WebUrl)
		}
		if (WebOffice.WebOpen()) {                                            //�򿪸��ĵ�    ����OfficeServer  �����ĵ�OPTION="LOADFILE"
			WebOffice.setEditType(editType);                                //EditType:�༭����  ��ʽһ   WebOpen֮��
			WebOffice.VBASetUserName(WebOffice.UserName);                   //�����û���
			// getEditVersion();                                               //�ж��Ƿ�������office             //���ĵ�ʱ��ʾ��дǩ��������
			WebOffice.ShowCustomToolbar(false);                             //������дǩ��������
			StatusMsg(WebOffice.Status);
			//���ļ����� �ָ� ԭʼ�ļ���
			WebOffice.fileNewName = fileName.replace(tempFileExt,fileType);
			return true;
		}
	} catch (e) {
		return false;
	}
}
